Class: Aegis::Parser
- Inherits:
-
Object
- Object
- Aegis::Parser
- Defined in:
- lib/aegis/parser.rb
Instance Attribute Summary collapse
-
#atoms ⇒ Object
readonly
Returns the value of attribute atoms.
Class Method Summary collapse
Instance Method Summary collapse
- #action(*args, &block) ⇒ Object
- #allow(*args, &block) ⇒ Object
- #deny(*args, &block) ⇒ Object
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #namespace(*args, &block) ⇒ Object
- #parse(&block) ⇒ Object
- #reading(&block) ⇒ Object
- #resource(*args, &block) ⇒ Object
- #resources(*args, &block) ⇒ Object
- #writing(&block) ⇒ Object
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
10 11 12 |
# File 'lib/aegis/parser.rb', line 10 def initialize @atoms = [] end |
Instance Attribute Details
#atoms ⇒ Object (readonly)
Returns the value of attribute atoms.
4 5 6 |
# File 'lib/aegis/parser.rb', line 4 def atoms @atoms end |
Class Method Details
.parse(&block) ⇒ Object
6 7 8 |
# File 'lib/aegis/parser.rb', line 6 def self.parse(&block) Aegis::Parser.new.parse(&block) end |
Instance Method Details
#action(*args, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/aegis/parser.rb', line 19 def action(*args, &block) # useful warning for people upgrading from Aegis 2 raise "action blocks do not take block arguments. allow/deny blocks do." if block && block.arity > 0 split_definitions(*args) do |name, | @atoms.push({ :type => :action, :name => name.to_s, :options => , :children => Aegis::Parser.parse(&block) }) end end |
#allow(*args, &block) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/aegis/parser.rb', line 65 def allow(*args, &block) split_definitions(*args) do |role_name, | @atoms.push({ :type => :allow, :role_name => role_name.to_s, :block => block }) end end |
#deny(*args, &block) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/aegis/parser.rb', line 75 def deny(*args, &block) split_definitions(*args) do |role_name, | @atoms.push({ :type => :deny, :role_name => role_name.to_s, :block => block }) end end |
#namespace(*args, &block) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aegis/parser.rb', line 32 def namespace(*args, &block) split_definitions(*args) do |name, | @atoms.push({ :type => :namespace, :name => name.to_s, :options => , :children => Aegis::Parser.parse(&block) }) end end |
#parse(&block) ⇒ Object
14 15 16 17 |
# File 'lib/aegis/parser.rb', line 14 def parse(&block) instance_eval(&block) if block atoms end |
#reading(&block) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/aegis/parser.rb', line 85 def reading(&block) block or raise "missing block" @atoms.push({ :type => :reading, :children => Aegis::Parser.parse(&block) }) end |
#resource(*args, &block) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/aegis/parser.rb', line 43 def resource(*args, &block) split_definitions(*args) do |name, | @atoms.push({ :type => :resource, :name => name.to_s, :options => , :children => Aegis::Parser.parse(&block) }) end end |
#resources(*args, &block) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/aegis/parser.rb', line 54 def resources(*args, &block) split_definitions(*args) do |name, | @atoms.push({ :type => :resources, :name => name.to_s, :options => , :children => Aegis::Parser.parse(&block) }) end end |
#writing(&block) ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/aegis/parser.rb', line 93 def writing(&block) block or raise "missing block" @atoms.push({ :type => :writing, :children => Aegis::Parser.parse(&block) }) end |