Module: Fogged::HasManyResources::ClassMethods

Defined in:
lib/fogged/has_many_resources.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  :dependent => :destroy,
  :class_name => "Fogged::Resource"
}

Instance Method Summary collapse

Instance Method Details

#has_many_resources(*args) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/fogged/has_many_resources.rb', line 11

def has_many_resources(*args)
  options = args.extract_options!
  unless options.include?(:through)
    fail(ArgumentError, ":through option is mandatory")
  end
  has_many :resources, DEFAULT_OPTIONS.merge(options)
  validate :_check_resources, :unless => "resources.empty?"
end