module Tableless::RelationExtension
Attributes
conditions[R]
Public Class Methods
new(klass, table)
click to toggle source
Calls superclass method
# File lib/active_scaffold/tableless.rb, line 93 def initialize(klass, table) super @conditions ||= [] end
Public Instance Methods
except(*skips)
click to toggle source
Calls superclass method
# File lib/active_scaffold/tableless.rb, line 117 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)
click to toggle source
# File lib/active_scaffold/tableless.rb, line 131 def execute_simple_calculation(operation, column_name, distinct) @klass.execute_simple_calculation(self, operation, column_name, distinct) end
find_one(id)
click to toggle source
# File lib/active_scaffold/tableless.rb, line 127 def find_one(id) @klass.find_one(id, self) || raise(ActiveRecord::RecordNotFound) end
initialize_copy(other)
click to toggle source
Calls superclass method
# File lib/active_scaffold/tableless.rb, line 98 def initialize_copy(other) @conditions = @conditions.try(:dup) || [] super end
merge(r)
click to toggle source
Calls superclass method
# File lib/active_scaffold/tableless.rb, line 111 def merge(r) super.tap do |merged| merged.conditions.concat r.conditions unless r.nil? || r.is_a?(Array) end end
to_a()
click to toggle source
# File lib/active_scaffold/tableless.rb, line 123 def to_a @klass.find_all(self) end
where(opts, *rest)
click to toggle source
# File lib/active_scaffold/tableless.rb, line 103 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