Class/Module Index [+]

Quicksearch

Gorillib::Model::ClassMethods

Modifies the Gorillib metaprogramming to handle deep recursion on Gorillib::Model collections which would prefer to handle arbitrarily complex resolution requirements via their (custom) receive! method

Public Instance Methods

define_collection_receiver(field) click to toggle source
# File lib/gorillib/resolution.rb, line 27
def define_collection_receiver(field)
 collection_field_name = field.name; collection_type = field.type
  # @param  [Array[Object],Hash[Object]] the collection to merge
  # @return [Gorillib::Collection] the updated collection
  define_meta_module_method("receive_#{collection_field_name}", true) do |coll, &block|
    begin
      existing = read_attribute(collection_field_name)
      if existing and (not collection_type.native?(coll) or existing.respond_to?(:receive!))
        existing.receive!(coll, &block)
      else
        write_attribute(collection_field_name, coll)
      end
    rescue StandardError => err ; err.polish("#{self.class} #{collection_field_name} collection on #{coll}'") rescue nil ; raise ; end
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.