Class: Dumbo::Operator
Instance Attribute Summary collapse
-
#commutator ⇒ Object
Returns the value of attribute commutator.
-
#function_name ⇒ Object
Returns the value of attribute function_name.
-
#hashes ⇒ Object
Returns the value of attribute hashes.
-
#join ⇒ Object
Returns the value of attribute join.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#leftarg ⇒ Object
Returns the value of attribute leftarg.
-
#merges ⇒ Object
Returns the value of attribute merges.
-
#name ⇒ Object
Returns the value of attribute name.
-
#negator ⇒ Object
Returns the value of attribute negator.
-
#restrict ⇒ Object
Returns the value of attribute restrict.
-
#result_type ⇒ Object
Returns the value of attribute result_type.
-
#rightarg ⇒ Object
Returns the value of attribute rightarg.
Attributes inherited from PgObject
Instance Method Summary collapse
Methods inherited from PgObject
#downgrade, #execute, #get, identfied_by, #identify, #initialize, #upgrade
Constructor Details
This class inherits a constructor from Dumbo::PgObject
Instance Attribute Details
#commutator ⇒ Object
Returns the value of attribute commutator.
3 4 5 |
# File 'lib/dumbo/operator.rb', line 3 def commutator @commutator end |
#function_name ⇒ Object
Returns the value of attribute function_name.
3 4 5 |
# File 'lib/dumbo/operator.rb', line 3 def function_name @function_name end |
#hashes ⇒ Object
Returns the value of attribute hashes.
3 4 5 |
# File 'lib/dumbo/operator.rb', line 3 def hashes @hashes end |
#join ⇒ Object
Returns the value of attribute join.
3 4 5 |
# File 'lib/dumbo/operator.rb', line 3 def join @join end |
#kind ⇒ Object
Returns the value of attribute kind.
3 4 5 |
# File 'lib/dumbo/operator.rb', line 3 def kind @kind end |
#leftarg ⇒ Object
Returns the value of attribute leftarg.
3 4 5 |
# File 'lib/dumbo/operator.rb', line 3 def leftarg @leftarg end |
#merges ⇒ Object
Returns the value of attribute merges.
3 4 5 |
# File 'lib/dumbo/operator.rb', line 3 def merges @merges end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/dumbo/operator.rb', line 3 def name @name end |
#negator ⇒ Object
Returns the value of attribute negator.
3 4 5 |
# File 'lib/dumbo/operator.rb', line 3 def negator @negator end |
#restrict ⇒ Object
Returns the value of attribute restrict.
3 4 5 |
# File 'lib/dumbo/operator.rb', line 3 def restrict @restrict end |
#result_type ⇒ Object
Returns the value of attribute result_type.
3 4 5 |
# File 'lib/dumbo/operator.rb', line 3 def result_type @result_type end |
#rightarg ⇒ Object
Returns the value of attribute rightarg.
3 4 5 |
# File 'lib/dumbo/operator.rb', line 3 def rightarg @rightarg end |
Instance Method Details
#drop ⇒ Object
68 69 70 |
# File 'lib/dumbo/operator.rb', line 68 def drop "DROP OPERATOR #{name};" end |
#load_attributes ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/dumbo/operator.rb', line 18 def load_attributes result = execute <<-SQL SELECT op.oprname AS name, op.oprkind AS kind, op.oprcanhash AS hashes, op.oprcanmerge AS merges, lt.typname AS leftarg, rt.typname AS rightarg, et.typname AS result_type, co.oprname AS commutator, ne.oprname AS negator, op.oprcode AS function_name, op.oprjoin AS join, op.oprrest AS restrict, description FROM pg_operator op LEFT OUTER JOIN pg_type lt ON lt.oid=op.oprleft LEFT OUTER JOIN pg_type rt ON rt.oid=op.oprright JOIN pg_type et on et.oid=op.oprresult LEFT OUTER JOIN pg_operator co ON co.oid=op.oprcom LEFT OUTER JOIN pg_operator ne ON ne.oid=op.oprnegate LEFT OUTER JOIN pg_description des ON des.objoid=op.oid WHERE op.oid = #{oid} SQL result.first.each do |k, v| send("#{k}=", v) rescue nil end result.first end |
#to_sql ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/dumbo/operator.rb', line 51 def to_sql attrs = [:leftarg, :rightarg, :commutator, :negator, :restrict, :join].reduce([]) do |mem, attr| mem << "#{attr.to_s.upcase} = #{public_send(attr)}" if public_send(attr) mem end atttr_str = attrs.join(",\n ") attrs << ",\n HASHES" if hashes attrs << ",\n MERGES" if merges <<-SQL.gsub(/^ {6}/, '') CREATE OPERATOR #{name} ( PROCEDURE = #{function_name}, #{atttr_str} ); SQL end |