Class: Decidim::CustomUserFields::FieldDefinition
- Inherits:
-
Object
- Object
- Decidim::CustomUserFields::FieldDefinition
- Extended by:
- Forwardable
- Defined in:
- lib/decidim/custom_user_fields/field_definition.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name, kwargs) ⇒ FieldDefinition
constructor
A new instance of FieldDefinition.
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
#field ⇒ Object (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 |
#name ⇒ Object (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 |
#type ⇒ Object (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 |