Module: SimpleFormObject::ClassMethods

Defined in:
lib/simple_form_object.rb

Instance Method Summary collapse

Instance Method Details

#_attribute(attribute_name) ⇒ Object



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

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

#_attributesObject



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

def _attributes
  @_attributes ||= []
end

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



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

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

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

#model_nameObject



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

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