class Gorillib::Model::SimpleCollectionField

Public Class Methods

new(model, name, type, options={}) click to toggle source

field :collection_attrs, Hash, default: Hash.new, doc: “Extra attributes to pass to the collection on creation – eg. key_method”

Calls superclass method Gorillib::Model::Field::new
# File lib/gorillib/model/field.rb, line 136
def initialize(model, name, type, options={})
  super
  collection_type = self.type
  item_type       = self.item_type
  key_method      = options[:key_method] if options[:key_method]
  raise "Please supply an item type for #{self.inspect} -- eg 'collection #{name.inspect}, of: FooClass'" unless item_type
  self.default ||= ->{ collection_type.new(item_type: item_type, belongs_to: self, key_method: key_method) }
end

Public Instance Methods

inscribe_methods(model) click to toggle source
Calls superclass method Gorillib::Model::Field#inscribe_methods
# File lib/gorillib/model/field.rb, line 145
def inscribe_methods(model)
  super
  model.__send__(:define_collection_receiver, self)
end