Sha256: d1086da71a5a95488aff1cb8d35803979e0474c1b64c1e2e575d66a5e9e1dd6e

Contents?: true

Size: 768 Bytes

Versions: 25

Compression:

Stored size: 768 Bytes

Contents

module CanTango
  module Rules
    module Dsl
      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

      # creates a scope that enforces either using the user or user_account for determining relationship matches on the models
      def scope name, &block
        yield CanTango::Rules::Scope.new name, self, &block
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
cantango-core-0.1.2 lib/cantango/rules/dsl.rb
cantango-core-0.1.1 lib/cantango/rules/dsl.rb
cantango-core-0.1.0 lib/cantango/rules/dsl.rb
cantango-0.9.4.7 lib/cantango/rules/dsl.rb
cantango-0.9.4.6 lib/cantango/rules/dsl.rb
cantango-0.9.4.5 lib/cantango/rules/dsl.rb
cantango-0.9.4.3 lib/cantango/rules/dsl.rb
cantango-0.9.4.2 lib/cantango/rules/dsl.rb
cantango-0.9.4.1 lib/cantango/rules/dsl.rb
cantango-0.9.4 lib/cantango/rules/dsl.rb
cantango-0.9.3.2 lib/cantango/rules/dsl.rb
cantango-0.8.9.5 lib/cantango/rules/dsl.rb
cantango-0.8.9.4 lib/cantango/rules/dsl.rb
cantango-0.8.9.3 lib/cantango/rules/dsl.rb
cantango-0.8.9.2 lib/cantango/rules/dsl.rb
cantango-0.8.9.1 lib/cantango/rules/dsl.rb
cantango-0.8.9 lib/cantango/rules/dsl.rb
cantango-0.8.8.1 lib/cantango/rules/dsl.rb
cantango-0.8.8 lib/cantango/rules/dsl.rb
cantango-0.8.7 lib/cantango/rules/dsl.rb