Class: CloudSesame::Query::AST::Literal
- Inherits:
-
Object
- Object
- CloudSesame::Query::AST::Literal
- Defined in:
- lib/cloud_sesame/query/ast/literal.rb
Constant Summary collapse
- SINGLE_QUATE =
Regexp.new(/\'/).freeze
- ESCAPE_QUATE =
"\\'".freeze
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #applied(included) ⇒ Object
- #as_field ⇒ Object
- #compile(detailed = false) ⇒ Object
-
#initialize(field, value, options = {}) ⇒ Literal
constructor
A new instance of Literal.
- #is_for(field, options = {}) ⇒ Object
Constructor Details
#initialize(field, value, options = {}) ⇒ Literal
Returns a new instance of Literal.
11 12 13 14 15 |
# File 'lib/cloud_sesame/query/ast/literal.rb', line 11 def initialize(field, value, = {}) @field = field @options = @value = LazyObject.new { ([:type] || Value).parse(value) } if value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/cloud_sesame/query/ast/literal.rb', line 9 def value @value end |
Instance Method Details
#applied(included) ⇒ Object
22 23 24 |
# File 'lib/cloud_sesame/query/ast/literal.rb', line 22 def applied(included) { field: @field, value: @value, included: included } if @value end |
#as_field ⇒ Object
26 27 28 |
# File 'lib/cloud_sesame/query/ast/literal.rb', line 26 def as_field @options[:as] || @field end |
#compile(detailed = false) ⇒ Object
30 31 32 |
# File 'lib/cloud_sesame/query/ast/literal.rb', line 30 def compile(detailed = false) (detailed ? detailed_format : standard_format) if @value end |
#is_for(field, options = {}) ⇒ Object
17 18 19 20 |
# File 'lib/cloud_sesame/query/ast/literal.rb', line 17 def is_for(field, = {}) @field = field @options.merge! end |