Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first implementation of dirty_tracking (fails test suite) #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/netbox_client_ruby/entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ def reload
self
end

def changed?
!dirty_data.empty?
end

def save
return post unless ids_set?
patch
Expand Down Expand Up @@ -200,6 +204,11 @@ def method_missing(name_as_symbol, *args, &block)

return super if not_this_classes_business

if ids_set? and data[name[0..-2]] == args[0]
dirty_data.delete name[0..-2]
return args[0]
end

dirty_data[name[0..-2]] = args[0]
return args[0]
end
Expand Down