Module: CanTango::Rules::Dsl

Included in:
CanTango::Rules
Defined in:
lib/cantango/rules/dsl.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/cantango/rules/dsl.rb', line 4

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_account
        relation = UserRelation.new :#{relationship}, self, scope, *models, &block
        yield relation if block
        relation
      end
    }
  end
end

Instance Method Details

#scope(name) {|CanTango::Rules::Scope.new name, self, &block| ... } ⇒ Object

creates a scope that enforces either using the user or user_account for determining relationship matches on the models

Yields:



19
20
21
# File 'lib/cantango/rules/dsl.rb', line 19

def scope name, &block
  yield CanTango::Rules::Scope.new name, self, &block
end