Sha256: 174f2a6ba97ebdd8d197045cda85c2ac149d2331017a5db7b47b23084f66ef43

Contents?: true

Size: 607 Bytes

Versions: 21

Compression:

Stored size: 607 Bytes

Contents

module CanTango
  class PermissionEngine < Engine
    module Parser
      class Relationship < Rule
        def parse
          match = target[/(\w+)#(\w+)=(.+)/]
          @target = match[$1]
          lstat = match[$2]
          rstat = match[$3]

          model_class = try_class
          raise "#{model_class} has no ##{lstat}!" if !model_class.new.respond_to?(lstat.to_sym)
          conditions = ":#{lstat} => #{rstat}"

          target_and_conditions = [ target, conditions ].compact.join(', ')
          "#{method}(:#{action}, #{target_and_conditions})"
        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/relationship.rb
cantango-0.9.4.6 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.9.4.5 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.9.4.3 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.9.4.2 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.9.4.1 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.9.4 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.9.3.2 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.8.9.5 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.8.9.4 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.8.9.3 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.8.9.2 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.8.9.1 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.8.9 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.8.8.1 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.8.8 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.8.7 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.8.6.2 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.8.6.1 lib/cantango/permission_engine/parser/relationship.rb
cantango-0.8.6 lib/cantango/permission_engine/parser/relationship.rb