Class: Erbac::Generators::ErbacGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/erbac/erbac_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_initializer_fileObject



49
50
51
# File 'lib/generators/erbac/erbac_generator.rb', line 49

def copy_initializer_file
  template "initializer.rb", "config/initializers/erbac.rb"
end

#init_erbac_optionsObject

def show_parameters

puts "user:    " + self.user
puts "auth_item:       " + self.options[:auth_item].inspect
puts "auth_item_child: " + self.options[:auth_item_child].inspect
puts "auth_assignment: " + self.options[:auth_assignment].inspect
puts "options:         " + options.inspect

end



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/generators/erbac/erbac_generator.rb', line 34

def init_erbac_options
  # TODO: check the validity of the name

  # assert options.auth_item[0]
  options.auth_item[1] ||= options.auth_item[0].classify || Configure::AUTH_ITEM_CLASS
  options.auth_item[2] ||= options.auth_item[0].tableize || Configure::AUTH_ITEM_TABLE

  # assert options.auth_item_child[0]
  options.auth_item_child[1] || options.auth_item_child[0].tableize || Configure::AUTH_ITEM_CHILD_TABLE

  # assert options.auth_assignment[0]
  options.auth_assignment[1] || options.auth_assignment[0].classify || Configure::AUTH_ASSIGNMENT_CLASS
  options.auth_assignment[2] || options.auth_assignment[0].tableize || Configure::AUTH_ASSIGNMENT_TABLE
end

#inject_user_classObject



53
54
55
# File 'lib/generators/erbac/erbac_generator.rb', line 53

def inject_user_class
  invoke "erbac:user", [ self.user_class ]
end

#show_readmeObject



57
58
59
60
61
# File 'lib/generators/erbac/erbac_generator.rb', line 57

def show_readme
  if behavior == :invoke
    readme "README"
  end
end