Class: Philtre::PlaceHolder
- Inherits:
-
Sequel::SQL::Expression
- Object
- Sequel::SQL::Expression
- Philtre::PlaceHolder
- Defined in:
- lib/philtre/place_holder.rb
Instance Attribute Summary collapse
-
#bt ⇒ Object
readonly
Returns the value of attribute bt.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#sql_field ⇒ Object
readonly
Returns the value of attribute sql_field.
Instance Method Summary collapse
-
#initialize(name, sql_field = nil, bt = caller) ⇒ PlaceHolder
constructor
name is what gets replaced by the operation and correspondingly named value in the filter sql_field is the name of the field that the operation will compare the named value to.
- #inspect ⇒ Object
- #small_source ⇒ Object
- #source ⇒ Object
- #to_s ⇒ Object
-
#to_s_append(ds, s) ⇒ Object
this is inserted into the generated SQL from a dataset that contains PlaceHolder instances.
Constructor Details
#initialize(name, sql_field = nil, bt = caller) ⇒ PlaceHolder
name is what gets replaced by the operation and correspondingly named value in the filter sql_field is the name of the field that the operation will compare the named value to.
5 6 7 8 9 10 11 |
# File 'lib/philtre/place_holder.rb', line 5 def initialize( name, sql_field = nil, bt = caller ) # backtrace @bt = bt @name = name @sql_field = sql_field end |
Instance Attribute Details
#bt ⇒ Object (readonly)
Returns the value of attribute bt.
13 14 15 |
# File 'lib/philtre/place_holder.rb', line 13 def bt @bt end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/philtre/place_holder.rb', line 14 def name @name end |
#sql_field ⇒ Object (readonly)
Returns the value of attribute sql_field.
15 16 17 |
# File 'lib/philtre/place_holder.rb', line 15 def sql_field @sql_field end |
Instance Method Details
#inspect ⇒ Object
33 34 35 |
# File 'lib/philtre/place_holder.rb', line 33 def inspect "#<#{self.class} #{name}:#{sql_field} @#{source}>" end |
#small_source ⇒ Object
29 30 31 |
# File 'lib/philtre/place_holder.rb', line 29 def small_source source.split('/').last(2).join('/').split(':')[0..1].join(':') end |
#source ⇒ Object
25 26 27 |
# File 'lib/philtre/place_holder.rb', line 25 def source bt[1] end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/philtre/place_holder.rb', line 37 def to_s "#{name}:#{sql_field} @#{small_source}" end |
#to_s_append(ds, s) ⇒ Object
this is inserted into the generated SQL from a dataset that contains PlaceHolder instances.
19 20 21 22 23 |
# File 'lib/philtre/place_holder.rb', line 19 def to_s_append( ds, s ) s << '$' << name.to_s s << ':' << sql_field.to_s if sql_field s << '/*' << small_source << '*/' end |