Class: Infold::Decorator

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/infold/property/decorator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field, **attrs) ⇒ Decorator

Returns a new instance of Decorator.



11
12
13
14
# File 'lib/infold/property/decorator.rb', line 11

def initialize(field, **attrs)
  @field = field
  super(**attrs)
end

Instance Attribute Details

#appendObject

Returns the value of attribute append.



7
8
9
# File 'lib/infold/property/decorator.rb', line 7

def append
  @append
end

#digitObject

Returns the value of attribute digit.



7
8
9
# File 'lib/infold/property/decorator.rb', line 7

def digit
  @digit
end

#fieldObject (readonly)

Returns the value of attribute field.



5
6
7
# File 'lib/infold/property/decorator.rb', line 5

def field
  @field
end

#kindObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/infold/property/decorator.rb', line 16

def kind
  if @kind.blank?
    if field.number?
      :number
    elsif %i(date datetime boolean).include?(field.type)
      field.type
    else
      :string
    end
  else
    @kind.to_sym
  end
end

#prependObject

Returns the value of attribute prepend.



7
8
9
# File 'lib/infold/property/decorator.rb', line 7

def prepend
  @prepend
end