Class: SkillTree::Parser::Initializer

Inherits:
Object
  • Object
show all
Defined in:
lib/skill_tree/parser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInitializer

Returns a new instance of Initializer.



22
23
24
# File 'lib/skill_tree/parser.rb', line 22

def initialize
  @acls = []
end

Instance Attribute Details

#aclsObject (readonly)

Returns the value of attribute acls.



21
22
23
# File 'lib/skill_tree/parser.rb', line 21

def acls
  @acls
end

Class Method Details

.default_acl_for(model) ⇒ Object



13
14
15
16
17
18
# File 'lib/skill_tree/parser.rb', line 13

def default_acl_for(model)
  @parser.acls.each do |acl|
    return acl.model if acl.default_for.to_s == model.class.table_name
  end if @parser
  nil
end

.parse!Object



8
9
10
11
# File 'lib/skill_tree/parser.rb', line 8

def parse!
  @parser = Initializer.new
  @parser.setup if SkillTree::Models::Acl.table_exists?
end

Instance Method Details

#acl(*args) {|acl| ... } ⇒ Object

Yields:



31
32
33
34
35
# File 'lib/skill_tree/parser.rb', line 31

def acl(*args)
  acl = AclParser.new(*args)
  yield acl
  @acls << acl
end

#setup(filename = 'config/acl.rb') ⇒ Object



26
27
28
29
# File 'lib/skill_tree/parser.rb', line 26

def setup(filename = 'config/acl.rb')
  instance_eval(File.read(Rails.root.join(filename)))
  save_db!
end