Module: Couchbase::Model::Dirty
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::Dirty
- Defined in:
- lib/couchbase/model/dirty.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #create_with_dirty(options = {}) ⇒ Object
-
#reload ⇒ Object
This is until my change review.couchbase.org/#/c/29745/ is in and released.
-
#save_if_changed(options = {}) ⇒ Object
FIXME Return value for “Fail” and “didn’t try” is the same.
- #save_with_dirty(options = {}) ⇒ Object
- #update_attributes_with_dirty(attrs) ⇒ Object
- #write_attribute(name, value) ⇒ Object
Instance Method Details
#create_with_dirty(options = {}) ⇒ Object
66 67 68 69 70 |
# File 'lib/couchbase/model/dirty.rb', line 66 def create_with_dirty( = {}) create_without_dirty().tap do |value| capture_previous_changes if value end end |
#reload ⇒ Object
This is until my change review.couchbase.org/#/c/29745/ is in and released.
41 42 43 44 45 46 47 48 |
# File 'lib/couchbase/model/dirty.rb', line 41 def reload raise Couchbase::Error::MissingId, 'missing id attribute' unless @id pristine = model.find(@id) update_attributes(pristine.attributes) @meta[:cas] = pristine.[:cas] clean! self end |
#save_if_changed(options = {}) ⇒ Object
FIXME Return value for “Fail” and “didn’t try” is the same
73 74 75 |
# File 'lib/couchbase/model/dirty.rb', line 73 def save_if_changed( = {}) save if changed? end |
#save_with_dirty(options = {}) ⇒ Object
60 61 62 63 64 |
# File 'lib/couchbase/model/dirty.rb', line 60 def save_with_dirty( = {}) save_without_dirty().tap do |value| capture_previous_changes if value end end |
#update_attributes_with_dirty(attrs) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/couchbase/model/dirty.rb', line 50 def update_attributes_with_dirty(attrs) begin @_ignore_dirty = attrs.delete(:_ignore_dirty) update_attributes_without_dirty(attrs) ensure @_ignore_dirty = false end end |
#write_attribute(name, value) ⇒ Object
33 34 35 36 37 |
# File 'lib/couchbase/model/dirty.rb', line 33 def write_attribute(name, value) send "#{name}_will_change!" unless @_ignore_dirty || send(name) == value @_attributes[name] = value end |