Sha256: 1ac9f62056d80be4bb902e0b7fc349dc8dd987653fbaac0fae06b0b407b0bb12
Contents?: true
Size: 1.56 KB
Versions: 20
Compression:
Stored size: 1.56 KB
Contents
module CassandraObject module AttributeMethods extend ActiveSupport::Concern include ActiveModel::AttributeMethods included do alias :[] :read_attribute alias :[]= :write_attribute attribute_method_suffix("", "=") end module ClassMethods def define_attribute_methods return if attribute_methods_generated? super(attribute_definitions.keys) @attribute_methods_generated = true end def attribute_methods_generated? @attribute_methods_generated ||= false end end def write_attribute(name, value) @attributes[name.to_s] = self.class.typecast_attribute(self, name, value) end def read_attribute(name) @attributes[name.to_s] end def attribute_exists?(name) @attributes.key?(name.to_s) end def attributes=(attributes) attributes.each do |(name, value)| send("#{name}=", value) end end def method_missing(method_id, *args, &block) if !self.class.attribute_methods_generated? self.class.define_attribute_methods send(method_id, *args, &block) else super end end def respond_to?(*args) self.class.define_attribute_methods unless self.class.attribute_methods_generated? super end protected def attribute_method?(name) !!attribute_definitions[name.to_sym] end private def attribute(name) read_attribute(name) end def attribute=(name, value) write_attribute(name, value) end end end
Version data entries
20 entries across 20 versions & 1 rubygems