Module: RoleMaking
- Defined in:
- lib/role_making.rb,
lib/role_making/role.rb,
lib/role_making/railtie.rb,
lib/role_making/version.rb,
lib/role_making/resourcing.rb,
lib/generators/role_making_generator.rb
Defined Under Namespace
Modules: Generators, Resourcing, Role Classes: Railtie
Constant Summary collapse
- VERSION =
"0.2.3"
Instance Attribute Summary collapse
-
#role_cname ⇒ Object
Returns the value of attribute role_cname.
-
#role_join_table_name ⇒ Object
Returns the value of attribute role_join_table_name.
-
#role_table_name ⇒ Object
Returns the value of attribute role_table_name.
Instance Method Summary collapse
Instance Attribute Details
#role_cname ⇒ Object
Returns the value of attribute role_cname.
6 7 8 |
# File 'lib/role_making.rb', line 6 def role_cname @role_cname end |
#role_join_table_name ⇒ Object
Returns the value of attribute role_join_table_name.
6 7 8 |
# File 'lib/role_making.rb', line 6 def role_join_table_name @role_join_table_name end |
#role_table_name ⇒ Object
Returns the value of attribute role_table_name.
6 7 8 |
# File 'lib/role_making.rb', line 6 def role_table_name @role_table_name end |
Instance Method Details
#role_making(options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/role_making.rb', line 8 def role_making( = {}) include Role #extend Dynamic if RoleMaking.dynamic_shortcuts .reverse_merge!({:role_cname => 'Role'}) self.role_cname = [:role_cname] self.role_table_name = self.role_cname.tableize.gsub(/\//, "_") default_join_table = [self.to_s.tableize.gsub(/\//, "_"),self.role_table_name].sort.join("_") .reverse_merge!({:role_join_table_name => default_join_table}) self.role_join_table_name = [:role_join_table_name] = { :class_name => [:role_cname].camelize } .merge!({ :join_table => self.role_join_table_name }) .merge!(.reject{ |k,v| ![ :before_add, :after_add, :before_remove, :after_remove ].include? k.to_sym }) has_and_belongs_to_many :roles, ** #has_and_belongs_to_many :roles, class_name: 'role', join_table: 'roles_users' #load_dynamic_methods if RoleMaking.dynamic_shortcuts end |