Class: ScopeBuilder::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/scope_builder/builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(proxy_scope) ⇒ Builder

Returns a new instance of Builder.



3
4
5
# File 'lib/scope_builder/builder.rb', line 3

def initialize(proxy_scope)
  @proxy_scope = proxy_scope
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/scope_builder/builder.rb', line 7

def method_missing(method, *args, &block)
  result = @proxy_scope.send(method, *args, &block)
  if result.class == ActiveRecord::NamedScope::Scope
    @proxy_scope = result
    self
  else
    result
  end
end

Instance Method Details

#inspectObject



21
22
23
# File 'lib/scope_builder/builder.rb', line 21

def inspect
  sprintf("#<%s:%#0x>", self.class.to_s, self.object_id)
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/scope_builder/builder.rb', line 17

def respond_to?(method)
  super || @proxy_scope.respond_to?(method)
end