Module: CanTango::Api::Ability::Dsl::Relationship

Included in:
CanTango::Api::Ability::Dsl, Scope
Defined in:
lib/cantango/api/ability/dsl/relationship.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/cantango/api/ability/dsl/relationship.rb', line 3

def self.included(base)
  ::CanTango.config.user.relations.each do |relationship|
    base.class_eval %{
      def #{relationship}_of *models, &block
        options = models.extract_options!
        scope = options[:scope] || :user
        relation = CanTango::Api::Ability::Relation.new :#{relationship}, self, scope, *models, &block
        yield relation if block
        relation
      end
    }
  end
end