Class: PipeLineDealer::CustomField

Inherits:
Model::Base show all
Defined in:
lib/pipe_line_dealer/model/custom_field.rb,
lib/pipe_line_dealer/custom_field/collection.rb

Defined Under Namespace

Classes: Collection

Constant Summary

Constants included from Model::Base::Concern::Persistance

Model::Base::Concern::Persistance::IGNORE_ATTRIBUTES_WHEN_SAVING

Instance Attribute Summary collapse

Attributes inherited from Model::Base

#attributes, #id

Instance Method Summary collapse

Methods inherited from Model::Base

#==, #attributes_for_saving, attrs, inherited, #initialize, pld_attr, #to_json, #to_s

Methods included from Model::Base::Concern::Persistance

#destroy, #new_record?, #persisted?, #save

Constructor Details

This class inherits a constructor from PipeLineDealer::Model::Base

Instance Attribute Details

Returns the value of attribute dropdown_entries.



4
5
6
# File 'lib/pipe_line_dealer/model/custom_field.rb', line 4

def dropdown_entries
  @dropdown_entries
end

Instance Method Details

#decode(model, value) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pipe_line_dealer/model/custom_field.rb', line 10

def decode(model, value)
  case field_type
  when "numeric"           then return value
  when "text"              then return value
  when "currency"          then return value
  when "dropdown"          then return decode_dropdown(model, value)
  when "multi_select"      then return decode_multi_select(model, value)
  when "multi_association" then return decode_multi_association(model, value)
  else; raise "Unkown PLD field type! #{field_type.inspect}"
  end
end

#encode(model, value) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/pipe_line_dealer/model/custom_field.rb', line 22

def encode(model, value)
  case field_type
  when "numeric"           then return value
  when "text"              then return value
  when "currency"          then return value
  when "dropdown"          then return encode_dropdown(model, value)
  when "multi_select"      then return encode_multi_select(model, value)
  when "multi_association" then return encode_multi_association(model, value)
  else; raise "Unkown PLD field type! #{field_type.inspect}"
  end
end

#process_attributesObject



6
7
8
# File 'lib/pipe_line_dealer/model/custom_field.rb', line 6

def process_attributes
  @dropdown_entries = @attributes.delete(:custom_field_label_dropdown_entries)
end