Module: Reform::Form::Scalar

Defined in:
lib/reform/form/scalar.rb

Defined Under Namespace

Modules: ClassMethods, Property

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

IDEA: what if every “leaf” property would be represented by a Scalar form?



3
4
5
6
# File 'lib/reform/form/scalar.rb', line 3

def self.included(base)
  base.extend ClassMethods
  base.extend Forwardable
end

Instance Method Details

#save!Object



16
17
# File 'lib/reform/form/scalar.rb', line 16

def save!
end

#scalarObject



12
13
14
# File 'lib/reform/form/scalar.rb', line 12

def scalar
  fields
end

#sync!Object



19
20
21
22
# File 'lib/reform/form/scalar.rb', line 19

def sync!
  model.replace(fields)
  # FIXME: how to sync that, if it's not responds to replace? or what if we don't want to write (e.g. image with paperdragon)?
end

#to_nested_hashObject



24
25
26
# File 'lib/reform/form/scalar.rb', line 24

def to_nested_hash
  scalar
end

#update!(object) ⇒ Object



8
9
10
# File 'lib/reform/form/scalar.rb', line 8

def update!(object)
  @fields = object # @scalar is "I came from the outside." or <ArbitraryObject>.
end