Module: BabySqueel

Defined in:
lib/baby_squeel.rb,
lib/baby_squeel/dsl.rb,
lib/baby_squeel/join.rb,
lib/baby_squeel/nodes.rb,
lib/baby_squeel/table.rb,
lib/baby_squeel/compat.rb,
lib/baby_squeel/errors.rb,
lib/baby_squeel/version.rb,
lib/baby_squeel/relation.rb,
lib/baby_squeel/resolver.rb,
lib/baby_squeel/operators.rb,
lib/baby_squeel/nodes/node.rb,
lib/baby_squeel/association.rb,
lib/baby_squeel/calculation.rb,
lib/baby_squeel/nodes/proxy.rb,
lib/baby_squeel/nodes/binary.rb,
lib/baby_squeel/nodes/function.rb,
lib/baby_squeel/nodes/grouping.rb,
lib/baby_squeel/join_dependency.rb,
lib/baby_squeel/nodes/attribute.rb,
lib/baby_squeel/active_record/base.rb,
lib/baby_squeel/active_record/where_chain.rb,
lib/baby_squeel/active_record/calculations.rb,
lib/baby_squeel/active_record/query_methods.rb,
lib/baby_squeel/active_record/version_helper.rb

Defined Under Namespace

Modules: ActiveRecord, Compat, JoinDependency, Nodes, Operators Classes: Association, AssociationAliasingError, AssociationComparisonError, AssociationNotFoundError, Calculation, DSL, Join, NotFoundError, PolymorphicNotSpecifiedError, PolymorphicSpecificationError, Relation, Resolver, Table

Constant Summary collapse

VERSION =
'3.0.0'.freeze

Class Method Summary collapse

Class Method Details

.[](thing, **kwargs) ⇒ Object

Get a BabySqueel table instance.

Examples

BabySqueel[Post]
BabySqueel[:posts]
BabySqueel[Post.arel_table]


33
34
35
36
37
38
39
40
41
# File 'lib/baby_squeel.rb', line 33

def [](thing, **kwargs)
  if thing.respond_to?(:model_name)
    Relation.new(thing)
  elsif thing.kind_of?(Arel::Table)
    Table.new(thing)
  else
    Table.new(Arel::Table.new(thing, **kwargs))
  end
end

.configure {|_self| ... } ⇒ Object

Configures BabySqueel using the given block

Yields:

  • (_self)

Yield Parameters:

  • _self (BabySqueel)

    the object that the method was called on



15
16
17
# File 'lib/baby_squeel.rb', line 15

def configure
  yield self
end

.enable_compatibility!Object

Turn on BabySqueel’s compatibility mode. This will make BabySqueel act more like Squeel.



21
22
23
24
# File 'lib/baby_squeel.rb', line 21

def enable_compatibility!
  require 'baby_squeel/compat'
  BabySqueel::Compat.enable!
end