Module: FmRest::Spyke::Model::Attributes
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::Dirty, ActiveModel::ForbiddenAttributesProtection, Orm
- Included in:
- FmRest::Spyke::Model
- Defined in:
- lib/fmrest/spyke/model/attributes.rb
Instance Method Summary collapse
-
#attributes ⇒ Object
ActiveModel::Dirty since version 5.2 assumes that if there's an we override the instance variable name used by Spyke to avoid issues.
-
#attributes=(new_attributes) ⇒ Object
In addition to the comments above on
attributes
, this also adds support for forbidden attributes. - #id=(value) ⇒ Object
- #reload(*args) ⇒ Object
- #save(*args) ⇒ Object
Methods included from Orm
Instance Method Details
#attributes ⇒ Object
ActiveModel::Dirty since version 5.2 assumes that if there's an we override the instance variable name used by Spyke to avoid issues.
TODO: Submit a pull request to Spyke so this isn't needed
120 121 122 |
# File 'lib/fmrest/spyke/model/attributes.rb', line 120 def attributes @_spyke_attributes end |
#attributes=(new_attributes) ⇒ Object
In addition to the comments above on attributes
, this also adds
support for forbidden attributes
127 128 129 130 |
# File 'lib/fmrest/spyke/model/attributes.rb', line 127 def attributes=(new_attributes) @_spyke_attributes ||= ::Spyke::Attributes.new(scope.params) use_setters(sanitize_for_mass_assignment(new_attributes)) if new_attributes && !new_attributes.empty? end |
#id=(value) ⇒ Object
101 102 103 104 |
# File 'lib/fmrest/spyke/model/attributes.rb', line 101 def id=(value) id_will_change! unless value == id super end |
#reload(*args) ⇒ Object
106 107 108 |
# File 'lib/fmrest/spyke/model/attributes.rb', line 106 def reload(*args) super.tap { |r| clear_changes_information } end |
#save(*args) ⇒ Object
110 111 112 |
# File 'lib/fmrest/spyke/model/attributes.rb', line 110 def save(*args) super.tap { |r| changes_applied_after_save if r } end |