Sha256: 7ffdf881de1f467ae3b4c4ddf1ef011474df6812d4978fd4b1e843fd9ebfa29d
Contents?: true
Size: 660 Bytes
Versions: 1
Compression:
Stored size: 660 Bytes
Contents
module Bagboy class Template < ActiveRecord::Base before_save :check_id def check_id data = parsed_data data['id'] = 'text' if data['id'] == nil self.data = data.to_json end def parsed_data self.data ||= '{}' JSON.parse( self.data ) end 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 def delete_item ( key ) data = parsed_data data.delete key self.data = data.to_json save end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bagboy-0.0.1 | app/models/bagboy/template.rb |