module Blackbeard::StorableAttributes::ClassMethods
Public Instance Methods
integer_attributes(*attributes)
click to toggle source
# File lib/blackbeard/storable_attributes.rb, line 23 def integer_attributes(*attributes) self.storable_attributes += attributes attributes.each do |method_name| method_name = method_name.to_sym send :define_method, method_name do storable_attributes_hash[method_name.to_s].to_i end send :define_method, "#{method_name}=".to_sym do |value| storable_attributes_hash[method_name.to_s] = value.to_i.to_s @storable_attributes_dirty = true end end end
json_attributes(*attributes)
click to toggle source
# File lib/blackbeard/storable_attributes.rb, line 37 def json_attributes(*attributes) self.storable_attributes += attributes attributes.each do |method_name| method_name = method_name.to_sym send :define_method, method_name do return nil if storable_attributes_hash[method_name.to_s].nil? JSON.parse(storable_attributes_hash[method_name.to_s]) end send :define_method, "#{method_name}=".to_sym do |value| storable_attributes_hash[method_name.to_s] = JSON.generate(value) @storable_attributes_dirty = true end end end
storable_attributes()
click to toggle source
# File lib/blackbeard/storable_attributes.rb, line 17 def storable_attributes return @storable_attributes if defined? @storable_attributes return self.superclass.storable_attributes if self.superclass.respond_to?(:storable_attributes) [] end
storable_attributes=(x)
click to toggle source
# File lib/blackbeard/storable_attributes.rb, line 13 def storable_attributes=(x) @storable_attributes = x end
string_attributes(*attributes)
click to toggle source
# File lib/blackbeard/storable_attributes.rb, line 52 def string_attributes(*attributes) self.storable_attributes += attributes attributes.each do |method_name| method_name = method_name.to_sym send :define_method, method_name do storable_attributes_hash[method_name.to_s] end send :define_method, "#{method_name}=".to_sym do |value| storable_attributes_hash[method_name.to_s] = value.to_s @storable_attributes_dirty = true end end end