Class: ParamsReady::Helpers::ArelBuilder::Callable

Inherits:
Object
  • Object
show all
Defined in:
lib/params_ready/helpers/arel_builder.rb

Direct Known Subclasses

Attribute::Callable, Table::Callable

Instance Method Summary collapse

Constructor Details

#initialize(proc) ⇒ Callable

Returns a new instance of Callable.



7
8
9
# File 'lib/params_ready/helpers/arel_builder.rb', line 7

def initialize(proc)
  @proc = proc
end

Instance Method Details

#to_arel(*args) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/params_ready/helpers/arel_builder.rb', line 11

def to_arel(*args)
  result = @proc.call(*args)
  case result
  when String, Symbol
    to_literal(result).to_arel(*args)
  else
    result
  end
end

#to_literalObject

Raises:



21
22
23
# File 'lib/params_ready/helpers/arel_builder.rb', line 21

def to_literal(*)
  raise ParamsReadyError, "Unimplemented: #{self.class.name}##{__callee__}"
end