Sha256: f59d6d684406b33213d42c729ba925ab0c87ea8ee35248ea6858e6b13282c33b

Contents?: true

Size: 669 Bytes

Versions: 21

Compression:

Stored size: 669 Bytes

Contents

module CanTango
  class PermissionEngine < Engine
    module Parser
      class Ownership < Rule
        attr_reader :model_class, :owner

        def parse
          match = target[/(\w+)#(\w+)/]

          @target = match[$1]
          @owner = match[$2]
          @model_class = try_class
          build_ownership_dsl
        end

        protected

        def build_ownership_dsl
          raise "#{model_class} has no ##{owner}!" if !model_class.new.respond_to?(owner.to_sym)
          ownership_dsl_lines
        end

        def ownership_dsl_lines
          "#{owner.singularize}_of(#{target}).#{method} :#{action}"
        end
      end
    end
  end
end



Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
cantango-0.9.4.7 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.9.4.6 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.9.4.5 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.9.4.3 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.9.4.2 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.9.4.1 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.9.4 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.9.3.2 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.8.9.5 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.8.9.4 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.8.9.3 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.8.9.2 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.8.9.1 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.8.9 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.8.8.1 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.8.8 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.8.7 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.8.6.2 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.8.6.1 lib/cantango/permission_engine/parser/ownership.rb
cantango-0.8.6 lib/cantango/permission_engine/parser/ownership.rb