Class: TaskMaster::CustomRequestField
- Inherits:
-
Object
- Object
- TaskMaster::CustomRequestField
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/task_master/custom_request_field.rb
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
{ required: false }
- VALID_TYPES =
%w(text textarea tel number email money date datetime-local bool checkbox radio)
- TYPES_WITH_OPTIONS =
%w(checkbox radio)
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#field_name ⇒ Object
Returns the value of attribute field_name.
-
#label ⇒ Object
Returns the value of attribute label.
-
#options ⇒ Object
Returns the value of attribute options.
-
#order ⇒ Object
Returns the value of attribute order.
-
#required ⇒ Object
Returns the value of attribute required.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #_initialize_required ⇒ Object
-
#initialize(attributes = {}) ⇒ CustomRequestField
constructor
A new instance of CustomRequestField.
- #to_hash ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ CustomRequestField
Returns a new instance of CustomRequestField.
13 14 15 16 |
# File 'app/models/task_master/custom_request_field.rb', line 13 def initialize(attributes = {}) attributes = attributes.reverse_merge(DEFAULT_ATTRIBUTES) super(attributes) end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
11 12 13 |
# File 'app/models/task_master/custom_request_field.rb', line 11 def description @description end |
#field_name ⇒ Object
Returns the value of attribute field_name.
11 12 13 |
# File 'app/models/task_master/custom_request_field.rb', line 11 def field_name @field_name end |
#label ⇒ Object
Returns the value of attribute label.
11 12 13 |
# File 'app/models/task_master/custom_request_field.rb', line 11 def label @label end |
#options ⇒ Object
Returns the value of attribute options.
11 12 13 |
# File 'app/models/task_master/custom_request_field.rb', line 11 def @options end |
#order ⇒ Object
Returns the value of attribute order.
11 12 13 |
# File 'app/models/task_master/custom_request_field.rb', line 11 def order @order end |
#required ⇒ Object
Returns the value of attribute required.
11 12 13 |
# File 'app/models/task_master/custom_request_field.rb', line 11 def required @required end |
#type ⇒ Object
Returns the value of attribute type.
11 12 13 |
# File 'app/models/task_master/custom_request_field.rb', line 11 def type @type end |
Instance Method Details
#_initialize_required ⇒ Object
40 41 42 |
# File 'app/models/task_master/custom_request_field.rb', line 40 def _initialize_required self.required = false if self.required.nil? end |
#to_hash ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/models/task_master/custom_request_field.rb', line 48 def to_hash hash = { type: type, label: label, description: description, field_name: field_name, required: required, order: order } if TYPES_WITH_OPTIONS.include?(type) hash[:options] = end hash end |