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

Classes: Options

Class Method Summary collapse

Class Method Details

.cloneObject

called in inheritable_attr :representer_class.



59
60
61
# File 'lib/reform/representer.rb', line 59

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

.default_inline_classObject



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

def self.default_inline_class
  options[:form_class]
end

.each(only_form = true, &block) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/reform/representer.rb', line 41

def self.each(only_form=true, &block)
  definitions = representable_attrs
  definitions = representable_attrs.find_all { |attr| attr[:form] } if only_form

  definitions.each(&block)
  self
end

.fields(&block) ⇒ Object

Returns hash of all property names.



37
38
39
# File 'lib/reform/representer.rb', line 37

def self.fields(&block)
  representable_attrs.find_all(&block).map(&:name)
end

.for(options) ⇒ Object



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

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