Module: ActiveScaffold::Tableless::RelationExtension
- Included in:
- Relation
- Defined in:
- lib/active_scaffold/tableless.rb
Instance Method Summary collapse
- #conditions ⇒ Object
- #except(*skips) ⇒ Object
- #execute_simple_calculation(operation, column_name, distinct) ⇒ Object
- #find_one(id) ⇒ Object
- #initialize(klass, table) ⇒ Object
- #initialize_copy(other) ⇒ Object
- #merge(r) ⇒ Object
- #to_a ⇒ Object
- #where(opts, *rest) ⇒ Object
Instance Method Details
#conditions ⇒ Object
86 87 88 |
# File 'lib/active_scaffold/tableless.rb', line 86 def conditions @conditions end |
#except(*skips) ⇒ Object
114 115 116 117 118 |
# File 'lib/active_scaffold/tableless.rb', line 114 def except(*skips) super.tap do |new_relation| new_relation.conditions = conditions unless skips.include? :where end end |
#execute_simple_calculation(operation, column_name, distinct) ⇒ Object
128 129 130 |
# File 'lib/active_scaffold/tableless.rb', line 128 def execute_simple_calculation(operation, column_name, distinct) @klass.execute_simple_calculation(self, operation, column_name, distinct) end |
#find_one(id) ⇒ Object
124 125 126 |
# File 'lib/active_scaffold/tableless.rb', line 124 def find_one(id) @klass.find_one(id, self) or raise ActiveRecord::RecordNotFound end |
#initialize(klass, table) ⇒ Object
90 91 92 93 |
# File 'lib/active_scaffold/tableless.rb', line 90 def initialize(klass, table) super @conditions ||= [] end |
#initialize_copy(other) ⇒ Object
95 96 97 98 |
# File 'lib/active_scaffold/tableless.rb', line 95 def initialize_copy(other) @conditions = @conditions.try(:dup) || [] super end |
#merge(r) ⇒ Object
108 109 110 111 112 |
# File 'lib/active_scaffold/tableless.rb', line 108 def merge(r) super.tap do |merged| merged.conditions.concat r.conditions unless r.nil? || r.is_a?(Array) end end |
#to_a ⇒ Object
120 121 122 |
# File 'lib/active_scaffold/tableless.rb', line 120 def to_a @klass.find_all(self) end |
#where(opts, *rest) ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/active_scaffold/tableless.rb', line 100 def where(opts, *rest) unless opts.blank? opts = opts.with_indifferent_access if opts.is_a? Hash @conditions << (rest.empty? ? opts : [opts, *rest]) end self end |