Class: SecurityRole
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SecurityRole
- Defined in:
- app/models/security_role.rb
Instance Method Summary collapse
-
#groups ⇒ Object
groups with this role.
-
#groups_not ⇒ Object
groups without this role.
-
#iid ⇒ Object
creating method because we only want a getter, not a setter for iid.
- #join_parties_security_roles ⇒ Object
- #to_data_hash ⇒ Object
- #to_xml(options = {}) ⇒ Object
-
#users ⇒ Object
users with this role.
-
#users_not ⇒ Object
users without this role.
Methods included from ErpTechSvcs::Utils::DefaultNestedSetMethods
#children_to_tree_hash, included, #is_descendant_of?, #leaf, #to_json_with_leaf, #to_label, #to_record_representation, #to_representation, #to_tree_hash
Instance Method Details
#groups ⇒ Object
groups with this role
42 43 44 |
# File 'app/models/security_role.rb', line 42 def groups Group.joins(:party).joins("JOIN #{join_parties_security_roles}") end |
#groups_not ⇒ Object
groups without this role
47 48 49 |
# File 'app/models/security_role.rb', line 47 def groups_not Group.joins(:party).joins("LEFT JOIN #{join_parties_security_roles}").where("parties_security_roles.security_role_id IS NULL") end |
#iid ⇒ Object
creating method because we only want a getter, not a setter for iid
23 24 25 |
# File 'app/models/security_role.rb', line 23 def iid self.internal_identifier end |
#join_parties_security_roles ⇒ Object
27 28 29 |
# File 'app/models/security_role.rb', line 27 def join_parties_security_roles "parties_security_roles ON parties_security_roles.party_id=parties.id AND parties_security_roles.security_role_id=#{self.id}" end |
#to_data_hash ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'app/models/security_role.rb', line 51 def to_data_hash hash = to_hash(:only => [:id, :description, :internal_identifier, :created_at, :updated_at]) if parent hash[:parent] = parent.to_data_hash end hash end |
#to_xml(options = {}) ⇒ Object
16 17 18 19 20 |
# File 'app/models/security_role.rb', line 16 def to_xml( = {}) default_only = [] [:only] = ([:only] || []) + default_only super() end |
#users ⇒ Object
users with this role
32 33 34 |
# File 'app/models/security_role.rb', line 32 def users User.joins(:party).joins("JOIN #{join_parties_security_roles}") end |
#users_not ⇒ Object
users without this role
37 38 39 |
# File 'app/models/security_role.rb', line 37 def users_not User.joins(:party).joins("LEFT JOIN #{join_parties_security_roles}").where("parties_security_roles.security_role_id IS NULL") end |