Module: Rolify
- Extended by:
- Configure
- Defined in:
- lib/rolify.rb,
lib/rolify/role.rb,
lib/rolify/dynamic.rb,
lib/rolify/railtie.rb,
lib/rolify/version.rb,
lib/rolify/resource.rb,
lib/rolify/configure.rb,
lib/rolify/adapters/base.rb,
lib/rolify/adapters/mongoid.rb,
lib/rolify/adapters/active_record.rb,
lib/generators/rolify/role/role_generator.rb
Defined Under Namespace
Modules: Adapter, Configure, Dynamic, Generators, Resource, Role Classes: Railtie
Constant Summary collapse
- VERSION =
"3.0.0"
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#role_cname ⇒ Object
Returns the value of attribute role_cname.
Instance Method Summary collapse
- #resourcify(options = { :role_cname => 'Role' }) ⇒ Object
- #role_class ⇒ Object
- #rolify(options = { :role_cname => 'Role' }) ⇒ Object
Methods included from Configure
configure, dynamic_shortcuts, dynamic_shortcuts=, orm, orm=, use_defaults, use_dynamic_shortcuts, use_mongoid
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
13 14 15 |
# File 'lib/rolify.rb', line 13 def adapter @adapter end |
#role_cname ⇒ Object
Returns the value of attribute role_cname.
13 14 15 |
# File 'lib/rolify.rb', line 13 def role_cname @role_cname end |
Instance Method Details
#resourcify(options = { :role_cname => 'Role' }) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/rolify.rb', line 27 def resourcify( = { :role_cname => 'Role' }) include Resource = { :class_name => [:role_cname].camelize } .merge!({ :as => :resource }) has_many :roles, self.role_cname = [:role_cname] self.adapter = Rolify::Adapter.const_get(Rolify.orm.camelize).new([:role_cname]) end |
#role_class ⇒ Object
36 37 38 |
# File 'lib/rolify.rb', line 36 def role_class self.role_cname.constantize end |
#rolify(options = { :role_cname => 'Role' }) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rolify.rb', line 15 def rolify( = { :role_cname => 'Role' }) include Role extend Dynamic if Rolify.dynamic_shortcuts = { :class_name => [:role_cname].camelize } .merge!({ :join_table => "#{self.to_s.tableize}_#{[:role_cname].tableize}" }) if Rolify.orm == "active_record" has_and_belongs_to_many :roles, load_dynamic_methods if Rolify.dynamic_shortcuts self.role_cname = [:role_cname] self.adapter = Rolify::Adapter.const_get(Rolify.orm.camelize).new([:role_cname]) end |