class Dao::Repository::Scope

Attributes

gateway[RW]
scope[RW]

Public Class Methods

new(gateway) click to toggle source
# File lib/dao/repository/scope.rb, line 6
def initialize(gateway)
  @gateway = gateway
  @scope = gateway.source
  @with = []
end

Public Instance Methods

apply() click to toggle source
# File lib/dao/repository/scope.rb, line 28
def apply
  gateway.map(scope, @with)
end
export_attributes_black_list() click to toggle source
# File lib/dao/repository/scope.rb, line 32
def export_attributes_black_list
  []
end
method_missing(method_name, *args, &block) click to toggle source
# File lib/dao/repository/scope.rb, line 12
def method_missing(method_name, *args, &block)
  with = extract_with(args)

  add_relations(with) if with.any?

  @scope = @gateway.chain(scope, method_name, args, &block)

  self
end
with(relations, options = {}) click to toggle source
# File lib/dao/repository/scope.rb, line 22
def with(relations, options = {})
  add_relations(relations, options)

  self
end

Private Instance Methods

add_relations(relations, options = {}) click to toggle source
# File lib/dao/repository/scope.rb, line 38
def add_relations(relations, options = {})
  @scope = @gateway.add_relations(scope, relations, options)
  @with += @gateway.serializable_relations(relations)
end
extract_with(args) click to toggle source
# File lib/dao/repository/scope.rb, line 47
def extract_with(args)
  if have_with_option?(args)
    with = extract_with_option(args)

    Array([with]).flatten.compact
  else
    []
  end
end
extract_with_option(args) click to toggle source
# File lib/dao/repository/scope.rb, line 63
def extract_with_option(args)
  options = args.pop

  options.delete(:with).tap do
    args << options unless options.empty?
  end
end
have_with_option?(args) click to toggle source
# File lib/dao/repository/scope.rb, line 57
def have_with_option?(args)
  options = args.last

  options.is_a?(Hash) && options[:with]
end
respond_to?(method_name, include_private = false) click to toggle source
Calls superclass method
# File lib/dao/repository/scope.rb, line 43
def respond_to?(method_name, include_private = false)
  scope.respond_to?(method_name, include_private) || super
end