Class: SpreadsheetBuilder::EnumColumn
- Inherits:
-
StringColumn
- Object
- StringColumn
- SpreadsheetBuilder::EnumColumn
- Defined in:
- backend/app/model/spreadsheet_builder.rb
Instance Attribute Summary collapse
-
#enum_name ⇒ Object
Returns the value of attribute enum_name.
-
#skip_values ⇒ Object
Returns the value of attribute skip_values.
Attributes inherited from StringColumn
#column, #index, #jsonmodel, #locked, #name, #property_name, #width
Instance Method Summary collapse
-
#initialize(jsonmodel, name, enum_name, opts = {}) ⇒ EnumColumn
constructor
A new instance of EnumColumn.
-
#sanitise_incoming_value(value) ⇒ Object
-
#value_for(enum_id) ⇒ Object
Methods inherited from StringColumn
Constructor Details
#initialize(jsonmodel, name, enum_name, opts = {}) ⇒ EnumColumn
Returns a new instance of EnumColumn.
123 124 125 126 127 |
# File 'backend/app/model/spreadsheet_builder.rb', line 123 def initialize(jsonmodel, name, enum_name, opts = {}) super(jsonmodel, name, {:column => "#{name}_id"}.merge(opts)) @enum_name = enum_name @skip_values = opts.fetch(:skip_enum_values, []) end |
Instance Attribute Details
#enum_name ⇒ Object
Returns the value of attribute enum_name
121 122 123 |
# File 'backend/app/model/spreadsheet_builder.rb', line 121 def enum_name @enum_name end |
#skip_values ⇒ Object
Returns the value of attribute skip_values
121 122 123 |
# File 'backend/app/model/spreadsheet_builder.rb', line 121 def skip_values @skip_values end |
Instance Method Details
#sanitise_incoming_value(value) ⇒ Object
133 134 135 |
# File 'backend/app/model/spreadsheet_builder.rb', line 133 def sanitise_incoming_value(value) EnumMapper.spreadsheet_value_to_enum(value) end |
#value_for(enum_id) ⇒ Object
129 130 131 |
# File 'backend/app/model/spreadsheet_builder.rb', line 129 def value_for(enum_id) EnumMapper.enum_id_to_spreadsheet_value(enum_id, @enum_name) end |