Class: Janko::TaggedColumn
- Inherits:
-
Object
- Object
- Janko::TaggedColumn
- Includes:
- Agrippa::Delegation, Agrippa::Mutable
- Defined in:
- lib/janko/tagged_column.rb
Instance Method Summary collapse
- #default_state ⇒ Object
- #has_tag?(tag) ⇒ Boolean
- #inspect ⇒ Object
-
#quoted(prefix = nil) ⇒ Object
FIXME: Quoting.
- #set(updates) ⇒ Object
- #tag(tag) ⇒ Object
- #tagged? ⇒ Boolean
- #to_bind(position) ⇒ Object
- #to_condition(left, right) ⇒ Object
- #to_s ⇒ Object
- #to_setter(left, right) ⇒ Object
- #to_typecast_bind(position) ⇒ Object
- #to_value(prefix = nil) ⇒ Object
- #type ⇒ Object
- #untag(tag) ⇒ Object
Instance Method Details
#default_state ⇒ Object
20 21 22 |
# File 'lib/janko/tagged_column.rb', line 20 def default_state { tags: {} } end |
#has_tag?(tag) ⇒ Boolean
40 41 42 |
# File 'lib/janko/tagged_column.rb', line 40 def has_tag?(tag) .has_key?(tag.to_s) end |
#inspect ⇒ Object
81 82 83 84 |
# File 'lib/janko/tagged_column.rb', line 81 def inspect children = "(#{.keys.join(" ")})" "#<#{self.class}:0x#{self.__id__.to_s(16)} #{name}#{children}>" end |
#quoted(prefix = nil) ⇒ Object
FIXME: Quoting
57 58 59 |
# File 'lib/janko/tagged_column.rb', line 57 def quoted(prefix = nil) prefix.nil? ? "\"#{name}\"" : "\"#{prefix}\".\"#{name}\"" end |
#set(updates) ⇒ Object
24 25 26 |
# File 'lib/janko/tagged_column.rb', line 24 def set(updates) chain(updates) end |
#tag(tag) ⇒ Object
28 29 30 31 32 |
# File 'lib/janko/tagged_column.rb', line 28 def tag(tag) tag = tag.to_s .merge!(tag => true) unless (tag == "") self end |
#tagged? ⇒ Boolean
44 45 46 |
# File 'lib/janko/tagged_column.rb', line 44 def tagged? not .empty? end |
#to_bind(position) ⇒ Object
73 74 75 |
# File 'lib/janko/tagged_column.rb', line 73 def to_bind(position) "$#{position}" end |
#to_condition(left, right) ⇒ Object
61 62 63 |
# File 'lib/janko/tagged_column.rb', line 61 def to_condition(left, right) "#{quoted(left)} = #{quoted(right)}" end |
#to_s ⇒ Object
48 49 50 |
# File 'lib/janko/tagged_column.rb', line 48 def to_s .keys.join(" ") end |
#to_setter(left, right) ⇒ Object
65 66 67 |
# File 'lib/janko/tagged_column.rb', line 65 def to_setter(left, right) "#{quoted} = #{maybe_on_update(left, right)}" end |
#to_typecast_bind(position) ⇒ Object
77 78 79 |
# File 'lib/janko/tagged_column.rb', line 77 def to_typecast_bind(position) "$#{position}::#{type}" end |
#to_value(prefix = nil) ⇒ Object
69 70 71 |
# File 'lib/janko/tagged_column.rb', line 69 def to_value(prefix = nil) maybe_wrap(nil, prefix) end |
#type ⇒ Object
52 53 54 |
# File 'lib/janko/tagged_column.rb', line 52 def type connection.column_type(table, name) end |
#untag(tag) ⇒ Object
34 35 36 37 38 |
# File 'lib/janko/tagged_column.rb', line 34 def untag(tag) tag = tag.to_s .reject! { |k| k == tag } unless (tag == "") self end |