Class: Granite::Form::Model::Attributes::Represents
- Defined in:
- lib/granite/form/model/attributes/represents.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #changed? ⇒ Boolean
-
#initialize(*_args) ⇒ Represents
constructor
A new instance of Represents.
- #sync ⇒ Object
Methods inherited from Attribute
#default, #defaultize, #normalize, #read, #read_before_type_cast, #write
Methods inherited from Base
#came_from_default?, #came_from_user?, #inspect_attribute, #pollute, #query, #read, #read_before_type_cast, #readonly?, #reset, #value_present?, #write, #write_value
Constructor Details
#initialize(*_args) ⇒ Represents
Returns a new instance of Represents.
8 9 10 11 12 13 |
# File 'lib/granite/form/model/attributes/represents.rb', line 8 def initialize(*_args) super set_default_value set_default_value_before_type_cast end |
Instance Method Details
#changed? ⇒ Boolean
19 20 21 22 23 24 25 |
# File 'lib/granite/form/model/attributes/represents.rb', line 19 def changed? if reflection..key?(:default) reference.public_send(reader) != read else owner.public_send("#{name}_changed?") end end |
#sync ⇒ Object
15 16 17 |
# File 'lib/granite/form/model/attributes/represents.rb', line 15 def sync reference.public_send(writer, read) if reference.respond_to?(writer) end |