Class: ParamsReady::Helpers::ArelBuilder::Attribute
- Inherits:
-
Object
- Object
- ParamsReady::Helpers::ArelBuilder::Attribute
show all
- Defined in:
- lib/params_ready/helpers/arel_builder.rb
Defined Under Namespace
Classes: Callable, Literal
Class Method Summary
collapse
Class Method Details
.instance(object, arel_table: nil) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/params_ready/helpers/arel_builder.rb', line 51
def self.instance(object, arel_table: nil)
case object
when Arel::Nodes::Node, Arel::Nodes::SqlLiteral, Arel::Attribute
raise ParamsReadyError, "Arel table unexpected" unless arel_table.nil? || arel_table == :none
ArelObject.new(object)
when Proc
raise ParamsReadyError, "Arel table unexpected" unless arel_table.nil? || arel_table == :none
Callable.new(object)
when String, Symbol
Literal.new(object, arel_table)
else
raise ParamsReadyError, "Unexpected type for arel builder: #{object.class.name}"
end
end
|