Class: Decidim::CustomUserFields::FieldDefinition

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/decidim/custom_user_fields/field_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, kwargs) ⇒ FieldDefinition

Returns a new instance of FieldDefinition.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/decidim/custom_user_fields/field_definition.rb', line 17

def initialize(name, kwargs)
  @name = name.to_s.to_sym
  @type = kwargs[:type]
  # TODO: parse kwargs
  case type
  when :text
    @field = Fields::TextField.new(self, kwargs)
  when :textarea
    @field = Fields::TextAreaField.new(self, kwargs)
  when :date
    @field = Fields::DateField.new(self, kwargs)
  else
    raise Error, "field type #{type} is not supported"
  end
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



8
9
10
# File 'lib/decidim/custom_user_fields/field_definition.rb', line 8

def field
  @field
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/decidim/custom_user_fields/field_definition.rb', line 8

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/decidim/custom_user_fields/field_definition.rb', line 8

def type
  @type
end