Module: Rbacfull
- Extended by:
- Configure
- Defined in:
- lib/rbacfull.rb,
lib/rbacfull/version.rb,
lib/generators/rbacfull/install_generator.rb
Defined Under Namespace
Classes: InstallGenerator
Constant Summary collapse
- VERSION =
"0.1.2"
- @@resource_types =
[]
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#resource_adapter ⇒ Object
Returns the value of attribute resource_adapter.
-
#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.
Class Method Summary collapse
Instance Method Summary collapse
- #rbacfull(options = {}) ⇒ Object
- #resourcify(association_name = :roles, options = {}) ⇒ Object
- #role_class ⇒ Object
- #scopify ⇒ Object
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
6 7 8 |
# File 'lib/rbacfull.rb', line 6 def adapter @adapter end |
#resource_adapter ⇒ Object
Returns the value of attribute resource_adapter.
6 7 8 |
# File 'lib/rbacfull.rb', line 6 def resource_adapter @resource_adapter end |
#role_cname ⇒ Object
Returns the value of attribute role_cname.
6 7 8 |
# File 'lib/rbacfull.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/rbacfull.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/rbacfull.rb', line 6 def role_table_name @role_table_name end |
Class Method Details
.resource_types ⇒ Object
65 66 67 |
# File 'lib/rbacfull.rb', line 65 def self.resource_types @@resource_types end |
Instance Method Details
#rbacfull(options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rbacfull.rb', line 9 def rbacfull( = {}) include Role extend Dynamic if Rbacfull.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}" .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 }) if Rbacfull.orm == "active_record" .merge!(.reject{ |k,v| ![ :before_add, :after_add, :before_remove, :after_remove ].include? k.to_sym }) has_and_belongs_to_many :roles, self.adapter = Rbacfull::Adapter::Base.create("role_adapter", self.role_cname, self.name) load_dynamic_methods if Rbacfull.dynamic_shortcuts end |
#resourcify(association_name = :roles, options = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rbacfull.rb', line 36 def resourcify(association_name = :roles, = {}) include Resource .reverse_merge!({ :role_cname => 'Role', :dependent => :destroy }) = { :class_name => [:role_cname].camelize, :as => :resource, :dependent => [:dependent] } self.role_cname = [:role_cname] self.role_table_name = self.role_cname.tableize.gsub(/\//, "_") has_many association_name, self.resource_adapter = Rbacfull::Adapter::Base.create("resource_adapter", self.role_cname, self.name) @@resource_types << self.name end |
#role_class ⇒ Object
60 61 62 63 |
# File 'lib/rbacfull.rb', line 60 def role_class return self.superclass.role_class unless self.instance_variable_defined? '@role_cname' self.role_cname.constantize end |