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, item_types, #opt_input, #process_data, #set

Class Method Details

.permitted_attributesObject



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

def self.permitted_attributes
  [ :data_boolean ]
end

.type_nameObject



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

def self.type_name
  'boolean'
end

Instance Method Details

#initObject



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

def init
  self.data = 0
  self
end

#to_sObject



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

def to_s
  self.data > 0 ? 'true' : 'false'
end

#update_data(value) ⇒ Object



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

def update_data( value )
  self.data = ( value == 'true' ) ? 1 : 0
  self.save
end