module ActiveScaffold::Tableless::RelationExtension

Public Class Methods

new(klass, *) click to toggle source
Calls superclass method
# File lib/active_scaffold/tableless.rb, line 83
def initialize(klass, *)
  super
  @conditions ||= []
end

Public Instance Methods

conditions() click to toggle source
# File lib/active_scaffold/tableless.rb, line 93
def conditions
  @conditions ||= []
end
except(*skips) click to toggle source
Calls superclass method
# File lib/active_scaffold/tableless.rb, line 112
def except(*skips)
  super.tap do |new_relation|
    unless new_relation.is_a?(RelationExtension)
      class << new_relation; include RelationExtension; end
    end
    new_relation.conditions.concat 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 125
def execute_simple_calculation(operation, column_name, distinct)
  @klass.execute_simple_calculation(self, operation, column_name, distinct)
end
exists?() click to toggle source
# File lib/active_scaffold/tableless.rb, line 133
def exists?
  size.positive?
end
find_one(id) click to toggle source
# File lib/active_scaffold/tableless.rb, line 121
def find_one(id)
  @klass.find_one(id, self) || raise(ActiveRecord::RecordNotFound)
end
implicit_order_column() click to toggle source
# File lib/active_scaffold/tableless.rb, line 129
def implicit_order_column
  @klass.implicit_order_column
end
initialize_copy(other) click to toggle source
Calls superclass method
# File lib/active_scaffold/tableless.rb, line 88
def initialize_copy(other)
  @conditions = @conditions&.dup || []
  super
end
merge(rel) click to toggle source
Calls superclass method
# File lib/active_scaffold/tableless.rb, line 106
def merge(rel)
  super.tap do |merged|
    merged.conditions.concat rel.conditions unless rel.nil? || rel.is_a?(Array)
  end
end
where(opts, *rest) click to toggle source
# File lib/active_scaffold/tableless.rb, line 97
def where(opts, *rest)
  if opts.present?
    opts = opts.with_indifferent_access if opts.is_a? Hash
    @conditions << (rest.empty? ? opts : [opts, *rest])
  end
  self
end
Also aliased as: where!
where!(opts, *rest)
Alias for: where

Private Instance Methods

exec_queries() click to toggle source
# File lib/active_scaffold/tableless.rb, line 139
def exec_queries
  @records = @klass.find_all(self)
  @loaded = true
  @records
end