Class: Ambition::Processor
- Inherits:
-
SexpProcessor
- Object
- SexpProcessor
- Ambition::Processor
- Includes:
- ActiveRecord::ConnectionAdapters::Quoting
- Defined in:
- lib/ambition/lib/ambition/processor.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#join_string ⇒ Object
readonly
Returns the value of attribute join_string.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Instance Method Summary collapse
-
#initialize ⇒ Processor
constructor
A new instance of Processor.
- #process_array(exp) ⇒ Object
- #process_dasgn_curr(exp) ⇒ Object
-
#process_error(exp) ⇒ Object
Processing methods.
- #process_proc(exp) ⇒ Object
- #sanitize(value) ⇒ Object
-
#to_s ⇒ Object
Helper methods.
Constructor Details
Instance Attribute Details
#join_string ⇒ Object (readonly)
Returns the value of attribute join_string.
7 8 9 |
# File 'lib/ambition/lib/ambition/processor.rb', line 7 def join_string @join_string end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/ambition/lib/ambition/processor.rb', line 7 def key @key end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
7 8 9 |
# File 'lib/ambition/lib/ambition/processor.rb', line 7 def prefix @prefix end |
Instance Method Details
#process_array(exp) ⇒ Object
34 35 36 37 38 |
# File 'lib/ambition/lib/ambition/processor.rb', line 34 def process_array(exp) arrayed = exp.map { |m| process(m) } exp.clear return arrayed.join(', ') end |
#process_dasgn_curr(exp) ⇒ Object
29 30 31 32 |
# File 'lib/ambition/lib/ambition/processor.rb', line 29 def process_dasgn_curr(exp) @receiver = exp.shift return @receiver.to_s end |
#process_error(exp) ⇒ Object
Processing methods
20 21 22 |
# File 'lib/ambition/lib/ambition/processor.rb', line 20 def process_error(exp) raise "Missing process method for sexp: #{exp.inspect}" end |
#process_proc(exp) ⇒ Object
24 25 26 27 |
# File 'lib/ambition/lib/ambition/processor.rb', line 24 def process_proc(exp) receiver, body = process(exp.shift), exp.shift return process(body) end |
#sanitize(value) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/ambition/lib/ambition/processor.rb', line 46 def sanitize(value) case value.to_s when 'true' then '1' when 'false' then '0' else ActiveRecord::Base.connection.quote(value) rescue quote(value) end end |
#to_s ⇒ Object
Helper methods
42 43 44 |
# File 'lib/ambition/lib/ambition/processor.rb', line 42 def to_s process(@block.to_sexp).squeeze(' ') end |