Class: Field::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/field/base.rb

Direct Known Subclasses

CNPJ, CPF, Email, Password, PersonType, Telephone, Text

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, fieldset) ⇒ Base

Returns a new instance of Base.



8
9
10
11
# File 'lib/field/base.rb', line 8

def initialize(name, fieldset)
  @name     = name
  @fieldset = fieldset
end

Instance Attribute Details

#fieldsetObject (readonly)

Returns the value of attribute fieldset.



6
7
8
# File 'lib/field/base.rb', line 6

def fieldset
  @fieldset
end

#formObject

Returns the value of attribute form.



4
5
6
# File 'lib/field/base.rb', line 4

def form
  @form
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/field/base.rb', line 3

def name
  @name
end

#valueObject

Returns the value of attribute value.



5
6
7
# File 'lib/field/base.rb', line 5

def value
  @value
end

Instance Method Details

#add_attributes(klass, options) ⇒ Object



13
14
15
# File 'lib/field/base.rb', line 13

def add_attributes(klass, options)
  klass.attribute name, self.attribute
end

#add_validations(klass, options) ⇒ Object



17
18
19
20
21
# File 'lib/field/base.rb', line 17

def add_validations(klass, options)
  if options.any?
    klass.send(:validates, name, options)
  end
end

#attributeObject



27
28
29
# File 'lib/field/base.rb', line 27

def attribute
  String
end

#form?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/field/base.rb', line 23

def form?
  false
end

#outputObject



31
32
33
# File 'lib/field/base.rb', line 31

def output
  value
end