Sha256: 41fefb337c567c18bb4bc189190c96546c3fefec83838f0b853fcb6486d56596
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
module ActiveData module Model module Attributes module Reflections class Attribute < Base def self.build target, generated_methods, name, *args, &block attribute = super(target, generated_methods, name, *args, &block) generate_methods name, generated_methods attribute end def self.generate_methods name, target target.class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{name} attribute('#{name}').read end def #{name}= value attribute('#{name}').write(value) end def #{name}? attribute('#{name}').query end def #{name}_before_type_cast attribute('#{name}').read_before_type_cast end def #{name}_default attribute('#{name}').default end def #{name}_values attribute('#{name}').enum.to_a end RUBY end def defaultizer @defaultizer ||= options[:default] end def enumerizer @enumerizer ||= options[:enum] || options[:in] end def normalizers @normalizers ||= Array.wrap(options[:normalize] || options[:normalizer] || options[:normalizers]) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_data-1.0.0 | lib/active_data/model/attributes/reflections/attribute.rb |