Class: Reform::Representer

Inherits:
Representable::Decorator
  • Object
show all
Extended by:
Uber::InheritableAttr
Includes:
Representable::Hash, Representable::Hash::AllowSymbols
Defined in:
lib/reform/representer.rb

Defined Under Namespace

Modules: WithOptions

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cloneObject

called in inheritable_attr :representer_class.



61
62
63
# File 'lib/reform/representer.rb', line 61

def self.clone # called in inheritable_attr :representer_class.
  Class.new(self) # By subclassing, representable_attrs.clone is called.
end

.for(options) ⇒ Object



55
56
57
58
59
# File 'lib/reform/representer.rb', line 55

def self.for(options)
  clone.tap do |representer|
    representer.options = options
  end
end

Instance Method Details

#fieldsObject

Returns hash of all property names.



45
46
47
# File 'lib/reform/representer.rb', line 45

def fields
  representable_attrs.map(&:name)
end

#nested_forms(&block) ⇒ Object



49
50
51
52
53
# File 'lib/reform/representer.rb', line 49

def nested_forms(&block)
  clone_config!.
    find_all { |attr| attr[:form] }.
    each(&block)
end