Class: ActiveAcl::Acts::AccessGroup::NestedSet
- Defined in:
- lib/active_acl/handler/nested_set.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#left_column ⇒ Object
readonly
Returns the value of attribute left_column.
-
#right_column ⇒ Object
readonly
Returns the value of attribute right_column.
Instance Method Summary collapse
- #group_sql(object_handler, target = false) ⇒ Object
-
#initialize(options) ⇒ NestedSet
constructor
A new instance of NestedSet.
-
#order_by(object_handler, target = false) ⇒ Object
“r_groups.##left_column - r_groups.##right_column ASC”.
Constructor Details
#initialize(options) ⇒ NestedSet
Returns a new instance of NestedSet.
6 7 8 9 10 11 12 13 |
# File 'lib/active_acl/handler/nested_set.rb', line 6 def initialize() @left_column = [:left_column] || :lft @right_column = [:right_column] || :rgt # :controller => ActiveAcl::OPTIONS[:default_group_selector_controller], # :action => ActiveAcl::OPTIONS[:default_group_selector_action]} end |
Instance Attribute Details
#left_column ⇒ Object (readonly)
Returns the value of attribute left_column.
5 6 7 |
# File 'lib/active_acl/handler/nested_set.rb', line 5 def left_column @left_column end |
#right_column ⇒ Object (readonly)
Returns the value of attribute right_column.
5 6 7 |
# File 'lib/active_acl/handler/nested_set.rb', line 5 def right_column @right_column end |
Instance Method Details
#group_sql(object_handler, target = false) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/active_acl/handler/nested_set.rb', line 14 def group_sql(object_handler,target = false) target_requester = (target ? 'target' : 'requester') if object_handler.habtm? "(SELECT DISTINCT g2.id FROM #{object_handler.join_table} ml LEFT JOIN #{object_handler.group_table_name} g1 ON ml.#{object_handler.association_foreign_key} = g1.id CROSS JOIN #{object_handler.group_table_name} g2 WHERE ml.#{object_handler.foreign_key} = %{#{target_requester}_id} AND (g2.#{left_column} <= g1.#{left_column} AND g2.#{right_column} >= g1.#{right_column}))" else "(SELECT DISTINCT g2.id FROM #{object_handler.group_table_name} g1 CROSS JOIN #{object_handler.group_table_name} g2 WHERE g1.id = %{#{target_requester}_group_id} AND (g2.#{left_column} <= g1.#{left_column} AND g2.#{right_column} >= g1.#{right_column}))" end #"r_groups.#{left_column} - r_groups.#{right_column} ASC" end |
#order_by(object_handler, target = false) ⇒ Object
“r_groups.##left_column - r_groups.##right_column ASC”
26 27 28 29 |
# File 'lib/active_acl/handler/nested_set.rb', line 26 def order_by(object_handler,target=false) target_requester = (target ? 't' : 'r') "#{target_requester}_groups.#{left_column} - #{target_requester}_groups.#{right_column} ASC" end |