Class: ContentsCore::ItemObject
- Inherits:
-
Item
show all
- Defined in:
- app/models/contents_core/item_object.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, #update_data
Class Method Details
.permitted_attributes ⇒ Object
28
29
30
|
# File 'app/models/contents_core/item_object.rb', line 28
def self.permitted_attributes
[ :data_hash ]
end
|
.type_name ⇒ Object
32
33
34
|
# File 'app/models/contents_core/item_object.rb', line 32
def self.type_name
'object'
end
|
Instance Method Details
#from_string(value) ⇒ Object
13
14
15
16
17
18
19
20
21
22
|
# File 'app/models/contents_core/item_object.rb', line 13
def from_string( value )
if value.is_a? String
val = {}
value.each_line do |line|
m = line.match( /([^:]*):(.*)/ )
val[m[1]] = m[2].strip if m && !m[1].blank?
end
self.data_hash = val
end
end
|
#init ⇒ Object
8
9
10
11
|
# File 'app/models/contents_core/item_object.rb', line 8
def init
self.data = {}
self
end
|
#to_s ⇒ Object
24
25
26
|
# File 'app/models/contents_core/item_object.rb', line 24
def to_s
self.data_hash ? self.data_hash.inject( '' ) { |k, v| k + v[0] + ': ' + v[1] + "\n" } : {}
end
|