Module: Arc::Quoting
- Included in:
- DataStores::AbstractDataStore
- Defined in:
- lib/arc/quoting.rb
Defined Under Namespace
Classes: CannotCastValueError
Instance Method Summary collapse
- #quote(value, klass = value.class) ⇒ Object
-
#quote_column(column_name) ⇒ Object
(also: #quote_column_name)
Quotes the column name.
-
#quote_table(table_name) ⇒ Object
(also: #quote_table_name)
Quotes the table name.
Instance Method Details
#quote(value, klass = value.class) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/arc/quoting.rb', line 19 def quote(value, klass=value.class) return quote_nil if (value.nil?) klass = value.class if klass.nil? if value.is_a? Class return quote_string value.name end case klass when String, Symbol method = "quote_#{klass.to_s}" return send method, value if respond_to? method, :include_private => true when Arc::DataStores::ObjectDefinitions::Column method = "quote_#{Arc::Casting::TYPES[klass.type.to_sym]}" return send(method, value) else while klass.name do method = "quote_#{klass.name.downcase.gsub(/class/,'')}" return send method, value if respond_to? method, :include_private => true klass = klass.superclass end end raise CannotCastValueError, "Unable to cast #{value}" end |
#quote_column(column_name) ⇒ Object Also known as: quote_column_name
Quotes the column name. Defaults to no quoting.
8 9 10 |
# File 'lib/arc/quoting.rb', line 8 def quote_column(column_name) "\"#{column_name}\"" end |
#quote_table(table_name) ⇒ Object Also known as: quote_table_name
Quotes the table name. Defaults to column name quoting.
14 15 16 |
# File 'lib/arc/quoting.rb', line 14 def quote_table(table_name) quote_column_name(table_name) end |