Sha256: 95dbacded44035ebf6e55933413864e55e0af3b1f5614d08842e8aebdd263ba7

Contents?: true

Size: 933 Bytes

Versions: 2

Compression:

Stored size: 933 Bytes

Contents

module FlexibleAccessibility
  class Permission
    attr_reader :resource
    attr_reader :actions

    def initialize(args={})
      @resource = args[:resource]
      @actions = args[:actions]
    end

    def controller
    	ApplicationResource.new(self.resource).controller
    end

    def namespace
    	ApplicationResource.new(self.resource).namespace
    end

		# TODO: this function may be recursive because nesting may be existed
    class << self
  	  def all
  			permissions = []
  			Utils.new.get_controllers.each do |scope|
  				namespace = scope.first.to_s
  			  scope.last.each do |resource|
  			  	resource = "#{namespace}/#{resource}" unless namespace == "default"
  			  	permissions << Permission.new(:resource => resource.gsub(/_controller/, ""), :actions => ApplicationResource.new(resource).klass.instance_variable_get(:@_verifiable_routes))
  			  end
  			end
  			permissions
    	end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flexible_accessibility-0.3.2 lib/flexible_accessibility/permission.rb
flexible_accessibility-0.3.1 lib/flexible_accessibility/permission.rb