Sha256: 5d753ddf9bb2c58d833103b03013f621cee75cc47f9b55c0b2007e4b9ca22329

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

module Documentation
  class Authorizer
    
    def initialize(controller)
      @controller = controller
    end
    
    def can_view_page?(page)
      true
    end

    def can_add_page?(page)
      true
    end

    def can_reposition_page?(page)
      true
    end

    def can_delete_page?(page)
      true
    end

    def can_edit_page?(page)
      true
    end
    
    def can_upload?(page)
      true
    end
    
    def can_search?
      true
    end
    
    def can_use_ui?
      true
    end
    
    def check!(action, object = :none)
      action_method_name = "can_#{action}?"
      if self.respond_to?(action_method_name)
        result = object == :none ? self.send(action_method_name) : self.send(action_method_name, object)
        if result != true
          raise Documentation::AccessDeniedError, "You are not permitted to perform this action."
        end
      else
        raise Documentation::Error, "Invalid authorizer check (#{action})"
      end
    end
    
    private
    
    def request
      controller.request
    end
    
    
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
documentation-1.0.9 lib/documentation/authorizer.rb
documentation-1.0.8 lib/documentation/authorizer.rb
documentation-1.0.7 lib/documentation/authorizer.rb
documentation-1.0.6 lib/documentation/authorizer.rb
local_documentation-1.0.0 lib/documentation/authorizer.rb
documentation-1.0.5 lib/documentation/authorizer.rb
documentation-1.0.4 lib/documentation/authorizer.rb
documentation-1.0.3 lib/documentation/authorizer.rb
documentation-1.0.2 lib/documentation/authorizer.rb