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.



66
67
68
# File 'lib/reform/representer.rb', line 66

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

.default_inline_classObject



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

def self.default_inline_class
  options[:form_class]
end

.for(options) ⇒ Object



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

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

Instance Method Details

#fieldsObject

Returns hash of all property names.



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

def fields
  representable_attrs.map(&:name)
end

#nested_forms(&block) ⇒ Object



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

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