module CouchRestAdapter::AttributeMethod
Public Instance Methods
attribute_methods()
click to toggle source
# File lib/couch_rest_adapter/attribute_method.rb, line 31 def attribute_methods _attributes.keys.map{ |attr| [attr, "#{attr}="] }.flatten end
base_id()
click to toggle source
# File lib/couch_rest_adapter/attribute_method.rb, line 35 def base_id File.basename self['_id'] end
method_without_equals(method_name)
click to toggle source
# File lib/couch_rest_adapter/attribute_method.rb, line 23 def method_without_equals method_name method_name.to_s.sub(/=$/,'').to_sym end
read_value(method_name)
click to toggle source
# File lib/couch_rest_adapter/attribute_method.rb, line 8 def read_value method_name singleton_class.class_eval do define_method(method_name) { self[method_name] } end send(method_name) end
read_write(method, value = nil)
click to toggle source
# File lib/couch_rest_adapter/attribute_method.rb, line 4 def read_write method, value = nil writer?(method) ? write_value(method, value) : read_value(method) end
write_value(method_name, value)
click to toggle source
# File lib/couch_rest_adapter/attribute_method.rb, line 15 def write_value method_name, value base_method_name = method_without_equals(method_name) singleton_class.class_eval do define_method(method_name) { |v| self[base_method_name] = v } end send(method_name, value) end
writer?(method_name)
click to toggle source
# File lib/couch_rest_adapter/attribute_method.rb, line 27 def writer? method_name method_name =~ /=$/ end