Module: SimpleFormObject::ClassMethods

Defined in:
lib/simple_form_object.rb

Instance Method Summary collapse

Instance Method Details

#_attribute(attribute_name) ⇒ Object



28
29
30
# File 'lib/simple_form_object.rb', line 28

def _attribute(attribute_name)
  _attributes.select{|a| a.name == attribute_name}.first
end

#_attributesObject



24
25
26
# File 'lib/simple_form_object.rb', line 24

def _attributes
  @_attributes ||= []
end

#_delegation_targetObject



20
21
22
# File 'lib/simple_form_object.rb', line 20

def _delegation_target
  @_delegation_target
end

#attribute(name, type = :string, options = {}) ⇒ Object



10
11
12
13
14
# File 'lib/simple_form_object.rb', line 10

def attribute(name, type = :string, options = {})
  self.send(:attr_accessor, name)

  _attributes << Attribute.new(name, type, options)
end

#delegate_all(options = {}) ⇒ Object



16
17
18
# File 'lib/simple_form_object.rb', line 16

def delegate_all(options = {})
  @_delegation_target = options.fetch(:to)
end

#model_nameObject



32
33
34
# File 'lib/simple_form_object.rb', line 32

def model_name
  ActiveModel::Name.new(self, nil, self.to_s.gsub(/Form$/, ''))
end