Class: ContentsCore::ItemBoolean

Inherits:
Item show all
Defined in:
app/models/contents_core/item_boolean.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Item

#as_json, #attr_id, #class_name, #config, #data_type, #editable, #on_after_initialize, #on_before_create, #opt_input, #process_data, #set, types, #validate_item

Class Method Details

.permitted_attributesObject



23
24
25
# File 'app/models/contents_core/item_boolean.rb', line 23

def self.permitted_attributes
  [ :data_boolean ]
end

.type_nameObject



27
28
29
# File 'app/models/contents_core/item_boolean.rb', line 27

def self.type_name
  'boolean'
end

Instance Method Details

#from_string(value) ⇒ Object



10
11
12
# File 'app/models/contents_core/item_boolean.rb', line 10

def from_string( value )
  self.data = ( value == 1 ) || ( value == '1' ) || ( value == 'true' ) || ( value == 'yes' )
end

#initObject



5
6
7
8
# File 'app/models/contents_core/item_boolean.rb', line 5

def init
  self.data = false unless self.data
  self
end

#to_sObject



19
20
21
# File 'app/models/contents_core/item_boolean.rb', line 19

def to_s
  self.data_boolean ? 'true' : 'false'
end

#update_data(value) ⇒ Object



14
15
16
17
# File 'app/models/contents_core/item_boolean.rb', line 14

def update_data( value )
  self.data = value
  self.save
end