Class: SpreadsheetBuilder::EnumColumn

Inherits:
StringColumn show all
Defined in:
backend/app/model/spreadsheet_builder.rb

Instance Attribute Summary collapse

Attributes inherited from StringColumn

#column, #index, #jsonmodel, #locked, #name, #property_name, #width

Instance Method Summary collapse

Methods inherited from StringColumn

#header_label, #path

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_nameObject

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_valuesObject

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