module Gorillib::Builder::ClassMethods
Public Instance Methods
collection(field_name, item_type, options={})
click to toggle source
FIXME: this interface is borked – it should not take the item_type in the second slot.
Calls superclass method
Gorillib::Model::ClassMethods#collection
# File lib/gorillib/builder.rb, line 111 def collection(field_name, item_type, options={}) super(field_name, Gorillib::ModelCollection, { :item_type => item_type, :field_type => ::Gorillib::Builder::GetsetCollectionField }.merge(options)) end
magic(field_name, type, options={})
click to toggle source
# File lib/gorillib/builder.rb, line 103 def magic(field_name, type, options={}) field(field_name, type, {:field_type => ::Gorillib::Builder::GetsetField}.merge(options)) end
member(field_name, type, options={})
click to toggle source
# File lib/gorillib/builder.rb, line 106 def member(field_name, type, options={}) field(field_name, type, {:field_type => ::Gorillib::Builder::MemberField}.merge(options)) end
Protected Instance Methods
define_attribute_getset(field)
click to toggle source
# File lib/gorillib/builder.rb, line 118 def define_attribute_getset(field) field_name = field.name; type = field.type define_meta_module_method(field_name, field.visibility(:reader)) do |*args, &block| begin getset(field, *args, &block) rescue StandardError => err ; err.polish("#{self.class}.#{field_name} type #{type} on #{args}'") rescue nil ; raise ; end end end
define_collection_getset(field)
click to toggle source
# File lib/gorillib/builder.rb, line 136 def define_collection_getset(field) field_name = field.name; item_type = field.item_type define_meta_module_method(field.singular_name, field.visibility(:collection_getset)) do |*args, &block| begin getset_collection_item(field, *args, &block) rescue StandardError => err ; err.polish("#{self.class}.#{field_name} c[#{item_type}] on #{args}'") rescue nil ; raise ; end end end
define_collection_tester(field)
click to toggle source
# File lib/gorillib/builder.rb, line 145 def define_collection_tester(field) plural_name = field.plural_name define_meta_module_method("has_#{field.singular_name}?", field.visibility(:collection_tester)) do |item_key| begin collection_of(plural_name).include?(item_key) rescue StandardError => err ; err.polish("#{self.class}.#{plural_name} having #{item_key}?'") rescue nil ; raise ; end end end
define_member_getset(field)
click to toggle source
# File lib/gorillib/builder.rb, line 127 def define_member_getset(field) field_name = field.name; type = field.type define_meta_module_method(field_name, field.visibility(:reader)) do |*args, &block| begin getset_member(field, *args, &block) rescue StandardError => err ; err.polish("#{self.class}.#{field_name} type #{type} on #{args}'") rescue nil ; raise ; end end end