Class: Dhatu::PromotionAttribute

Inherits:
ApplicationRecord show all
Includes:
Publishable
Defined in:
app/models/dhatu/promotion_attribute.rb

Constant Summary collapse

DATA_TYPES =

Data Type could be text, integer, date, list_drop_down (Select from a List), list_radio_button (Choose one) & boolean (Checkbox)

{"Text" => "text", "Integer" => "integer", "Date" => "date", "List (Drop Down)" => "list_drop_down", "List (Radio Button)" => "list_radio_button", "Boolean (Checkbox)" => "boolean"}
DATA_TYPES_REVERSE =
{"text" => "Text", "integer" => "Integer", "date" => "Date", "list_drop_down" => "List (Drop Down)", "list_radio_button" => "List (Radio Button)", "boolean" => "Boolean (Checkbox)"}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#values_stringObject

Returns the value of attribute values_string.



9
10
11
# File 'app/models/dhatu/promotion_attribute.rb', line 9

def values_string
  @values_string
end

Instance Method Details

#can_be_deleted?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'app/models/dhatu/promotion_attribute.rb', line 58

def can_be_deleted?
  true
end

#can_be_edited?Boolean

Permission Methods


Returns:

  • (Boolean)


54
55
56
# File 'app/models/dhatu/promotion_attribute.rb', line 54

def can_be_edited?
  true
end

#convert_string_values_to_arrayObject



43
44
45
# File 'app/models/dhatu/promotion_attribute.rb', line 43

def convert_string_values_to_array
  self.values = self.values_string.split(",") if self.values_string
end

#display_data_typeObject



39
40
41
# File 'app/models/dhatu/promotion_attribute.rb', line 39

def display_data_type
  DATA_TYPES_REVERSE[self.data_type]
end

#display_nameObject

Other Methods




35
36
37
# File 'app/models/dhatu/promotion_attribute.rb', line 35

def display_name
  self.name
end

#set_string_valuesObject



47
48
49
# File 'app/models/dhatu/promotion_attribute.rb', line 47

def set_string_values
  self.values_string = self.values.join(",") if ["list_drop_down", "list_radio_button", ""].include?(self.data_type.to_s)
end