Class: PGExaminer::Result::Function

Inherits:
Item
  • Object
show all
Defined in:
lib/pg_examiner/result/function.rb

Constant Summary collapse

EXCESS_WHITESPACE_REGEX =
/\s+/.freeze

Instance Attribute Summary

Attributes inherited from Item

#parent, #result, #row

Instance Method Summary collapse

Methods inherited from Item

#initialize, #inspect, #name, #oid

Methods inherited from Base

#==, #diff, #diffable_lists

Constructor Details

This class inherits a constructor from PGExaminer::Result::Item

Instance Method Details

#argument_typesObject



30
31
32
33
34
# File 'lib/pg_examiner/result/function.rb', line 30

def argument_types
  @argument_types ||= @row['proargtypes'].split.map do |oid|
    result.pg_type.find{|t| t['oid'] == oid}['name']
  end
end

#definitionObject



24
25
26
27
28
# File 'lib/pg_examiner/result/function.rb', line 24

def definition
  s = @row['definition'].strip
  s.gsub!(EXCESS_WHITESPACE_REGEX, ' ')
  s
end

#diffable_attrsObject



8
9
10
11
12
13
# File 'lib/pg_examiner/result/function.rb', line 8

def diffable_attrs
  {
    "name"        => "name",
    "proargmodes" => "argument modes",
  }
end

#diffable_methodsObject



15
16
17
18
19
20
21
22
# File 'lib/pg_examiner/result/function.rb', line 15

def diffable_methods
  {
    "argument_types" => "argument types",
    "return_type"    => "return type",
    "language"       => "language",
    "definition"     => "function definition",
  }
end

#languageObject



40
41
42
# File 'lib/pg_examiner/result/function.rb', line 40

def language
  @language ||= result.pg_language.find{|l| l['oid'] == @row['prolang']}['name']
end

#return_typeObject



36
37
38
# File 'lib/pg_examiner/result/function.rb', line 36

def return_type
  @return_type ||= result.pg_type.find{|t| t['oid'] == @row['prorettype']}['name']
end