Class: CanTango::PermissionEngine::Compiler

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCompiler

Returns a new instance of Compiler.



6
7
# File 'lib/cantango/permission_engine/compiler.rb', line 6

def initialize
end

Instance Attribute Details

#categoriesObject (readonly)

Returns the value of attribute categories.



4
5
6
# File 'lib/cantango/permission_engine/compiler.rb', line 4

def categories
  @categories
end

#permissionObject (readonly)

Returns the value of attribute permission.



4
5
6
# File 'lib/cantango/permission_engine/compiler.rb', line 4

def permission
  @permission
end

Instance Method Details

#can_eval(&block) ⇒ Object



22
23
24
# File 'lib/cantango/permission_engine/compiler.rb', line 22

def can_eval &block
  build_statements :can, &block
end

#cannot_eval(&block) ⇒ Object



26
27
28
# File 'lib/cantango/permission_engine/compiler.rb', line 26

def cannot_eval &block
  build_statements :cannot, &block
end

#compile!(permission) ⇒ Object



9
10
11
12
# File 'lib/cantango/permission_engine/compiler.rb', line 9

def compile! permission
  @permission = permission
  self
end

#eval_statementsObject



18
19
20
# File 'lib/cantango/permission_engine/compiler.rb', line 18

def eval_statements
  {:can => can_eval, :cannot => cannot_eval}
end

#to_hashieObject



14
15
16
# File 'lib/cantango/permission_engine/compiler.rb', line 14

def to_hashie
  Hashie::Mash.new(eval_statements)
end