Class: ThinkingSphinx::ActiveRecord::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/active_record/column.rb

Instance Method Summary (collapse)

Constructor Details

- (Column) initialize(*stack)



2
3
4
5
# File 'lib/thinking_sphinx/active_record/column.rb', line 2

def initialize(*stack)
  @stack = stack
  @name  = stack.pop
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method, *args, &block) (private)



37
38
39
40
41
# File 'lib/thinking_sphinx/active_record/column.rb', line 37

def method_missing(method, *args, &block)
  @stack << @name
  @name = method
  self
end

Instance Method Details

- (Object) __name



7
8
9
# File 'lib/thinking_sphinx/active_record/column.rb', line 7

def __name
  @name
end

- (Object) __path



11
12
13
# File 'lib/thinking_sphinx/active_record/column.rb', line 11

def __path
  @stack + [@name]
end

- (Object) __replace(stack, replacements)



15
16
17
18
19
20
21
# File 'lib/thinking_sphinx/active_record/column.rb', line 15

def __replace(stack, replacements)
  return [self] if string? || __stack[0..stack.length-1] != stack

  replacements.collect { |replacement|
    self.class.new *(replacement + __stack[stack.length..-1]), __name
  }
end

- (Object) __stack



23
24
25
# File 'lib/thinking_sphinx/active_record/column.rb', line 23

def __stack
  @stack
end

- (Boolean) string?



27
28
29
# File 'lib/thinking_sphinx/active_record/column.rb', line 27

def string?
  __name.is_a?(String)
end

- (Object) to_ary



31
32
33
# File 'lib/thinking_sphinx/active_record/column.rb', line 31

def to_ary
  [self]
end