Class: Aegis::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/aegis/compiler.rb

Constant Summary collapse

ATOM_GROUPS =
{
  :namespace  => :structure,
  :resource   => :structure,
  :resources  => :structure,
  :action     => :structure,
  :allow      => :sieve,
  :deny       => :sieve,
  :reading    => :sieve,
  :writing    => :sieve
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource) ⇒ Compiler

Returns a new instance of Compiler.



15
16
17
# File 'lib/aegis/compiler.rb', line 15

def initialize(resource)
  @resource = resource
end

Class Method Details

.compile(resource, atoms) ⇒ Object



32
33
34
# File 'lib/aegis/compiler.rb', line 32

def self.compile(resource, atoms)
  new(resource).compile(atoms)
end

Instance Method Details

#compile(atoms) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/aegis/compiler.rb', line 19

def compile(atoms)
  for atom in atoms
    case atom_group(atom)
    when :structure
      compile_structure(atom)
    when :sieve
      compile_sieve(atom)
    else
      unexpected_atom_type!(atom)
    end
  end
end