Class Authorization::Reader::DSLReader
In: lib/reader.rb
Parent: Object

Top-level reader, parses the methods privileges and authorization. authorization takes a block with authorization rules as described in AuthorizationRulesReader. The block to privileges defines privilege hierarchies, as described in PrivilegesReader.

Methods

load   new   parse  

Public Class methods

Loads and parses a DSL from the given file name.

[Source]

    # File lib/reader.rb, line 55
55:       def self.load (dsl_file)
56:         # TODO cache reader in production mode?
57:         reader = new
58:         reader.parse(File.read(dsl_file), dsl_file)
59:         reader
60:       end

[Source]

    # File lib/reader.rb, line 37
37:       def initialize ()
38:         @privileges_reader = PrivilegesReader.new
39:         @auth_rules_reader = AuthorizationRulesReader.new
40:       end

Public Instance methods

Parses a authorization DSL specification from the string given in dsl_data. Raises DSLSyntaxError if errors occur on parsing.

[Source]

    # File lib/reader.rb, line 44
44:       def parse (dsl_data, file_name = nil)
45:         if file_name
46:           DSLMethods.new(self).instance_eval(dsl_data, file_name)
47:         else
48:           DSLMethods.new(self).instance_eval(dsl_data)
49:         end
50:       rescue SyntaxError, NoMethodError, NameError => e
51:         raise DSLSyntaxError, "Illegal DSL syntax: #{e}"
52:       end

[Validate]