Class: Ambition::Context
- Inherits:
-
Object
- Object
- Ambition::Context
- Defined in:
- lib/ambition/adapters/active_record/context.rb
Instance Method Summary collapse
- #count(*args) ⇒ Object (also: #size)
- #count_with_deleted(*args) ⇒ Object
- #find(*args) ⇒ Object
- #find_with_deleted(*args) ⇒ Object
- #within(outer_scope, join_association) ⇒ Object
Instance Method Details
#count(*args) ⇒ Object Also known as: size
11 12 13 |
# File 'lib/ambition/adapters/active_record/context.rb', line 11 def count *args with_context_scope(to_hash) { owner.count *args } end |
#count_with_deleted(*args) ⇒ Object
16 17 18 |
# File 'lib/ambition/adapters/active_record/context.rb', line 16 def count_with_deleted *args with_context_scope(to_hash) { owner.count_with_deleted *args } end |
#find(*args) ⇒ Object
4 5 6 |
# File 'lib/ambition/adapters/active_record/context.rb', line 4 def find *args with_context_scope(to_hash) { owner.find *args } end |
#find_with_deleted(*args) ⇒ Object
7 8 9 |
# File 'lib/ambition/adapters/active_record/context.rb', line 7 def find_with_deleted *args with_context_scope(to_hash) { owner.find_with_deleted *args } end |
#within(outer_scope, join_association) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ambition/adapters/active_record/context.rb', line 20 def within outer_scope, join_association context = ambition_context unless outer_scope.nil? raise "#{owner} doesn't have a #{join_association.inspect} association. Make sure it's spelt and pluralized correctly and speficied as a symbol." unless context.owner.reflections.has_key?(join_association) (context.stash[:joins] ||= []).push(join_association).concat(outer_scope.stash[:joins] || []).uniq! context.clauses[:select].concat(outer_scope.clauses[:select]).uniq! end context end |