module Cot::FrameClassMethods
Attributes
attr_methods[RW]
inverted_mappings[RW]
inverted_search_mappings[RW]
mappings[RW]
missing_blocks[RW]
primary_key[RW]
search_mappings[RW]
value_blocks[RW]
Public Instance Methods
enum(name, &block)
click to toggle source
# File lib/cot/frame_class_methods.rb, line 17 def enum(name, &block) obj = Enum.new obj.instance_eval(&block) define_singleton_method name do obj end define_method name do obj end end
property(name, args = {}, &block)
click to toggle source
# File lib/cot/frame_class_methods.rb, line 28 def property(name, args = {}, &block) set_default_values prop = Property.new args prop.instance_eval(&block) if block set_blocks(name, prop) set_mappings(name, prop) @primary_key = name if prop.primary? define_property_methods name end
search_property(name, args = {})
click to toggle source
# File lib/cot/frame_class_methods.rb, line 12 def search_property(name, args = {}) key = args[:from] ? args[:from] : name @search_mappings[name] = key end
Private Instance Methods
define_property_methods(name)
click to toggle source
# File lib/cot/frame_class_methods.rb, line 65 def define_property_methods(name) define_method name do self[name] end define_method "#{name}=" do |value| public_send("#{name}_will_change!") unless value.eql?(self[name]) self[name] = value end define_attribute_method name end
set_blocks(name, prop)
click to toggle source
# File lib/cot/frame_class_methods.rb, line 42 def set_blocks(name, prop) @value_blocks[name] = prop.value @missing_blocks[name] = prop.missing end
set_default_values()
click to toggle source
Can’t seem to get an intialize in for the class, so we need to set these before we do stuff for property
# File lib/cot/frame_class_methods.rb, line 56 def set_default_values @mappings ||= {} @attr_methods ||= [] @search_mappings ||= {} @value_blocks ||= {} @missing_blocks ||= {} @primary_key ||= :id end
set_mappings(name, prop)
click to toggle source
# File lib/cot/frame_class_methods.rb, line 47 def set_mappings(name, prop) key = prop.from @mappings[key] = name if key @search_mappings[name] = key ? key : name if prop.searchable attr_methods << name end