Class: Bagboy::Template
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Bagboy::Template
- Defined in:
- app/models/bagboy/template.rb
Instance Method Summary collapse
Instance Method Details
#check_id ⇒ Object
6 7 8 9 10 |
# File 'app/models/bagboy/template.rb', line 6 def check_id data = parsed_data data['id'] = 'text' if data['id'] == nil self.data = data.to_json end |
#delete_item(key) ⇒ Object
25 26 27 28 29 30 |
# File 'app/models/bagboy/template.rb', line 25 def delete_item ( key ) data = parsed_data data.delete key self.data = data.to_json save end |
#item(key, value) ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/models/bagboy/template.rb', line 17 def item ( key, value ) data = parsed_data data[key.downcase] = value data = Hash[data.sort_by { |key, value| key }] self.data = data.to_json save end |
#parsed_data ⇒ Object
12 13 14 15 |
# File 'app/models/bagboy/template.rb', line 12 def parsed_data self.data ||= '{}' JSON.parse( self.data ) end |