Class: Piggly::Dumper::QualifiedType
- Defined in:
- lib/piggly/dumper/qualified_type.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(schema, name, array) ⇒ QualifiedType
constructor
A new instance of QualifiedType.
- #quote ⇒ Object
- #shorten ⇒ Object
- #table? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(schema, name, array) ⇒ QualifiedType
Returns a new instance of QualifiedType.
60 61 62 |
# File 'lib/piggly/dumper/qualified_type.rb', line 60 def initialize(schema, name, array) @schema, @name, @array = schema, name, array end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
25 26 27 |
# File 'lib/piggly/dumper/qualified_type.rb', line 25 def name @name end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
25 26 27 |
# File 'lib/piggly/dumper/qualified_type.rb', line 25 def schema @schema end |
Class Method Details
.parse(name, rest = nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/piggly/dumper/qualified_type.rb', line 27 def self.parse(name, rest = nil) if rest.to_s == "" schema = nil else schema = unquote(name) name = rest end case name when /(.*)\[\]$/ name = $1 array = "[]" else array = "" end if schema.to_s == "" fst, snd = name.split(".", 2) if snd.nil? new(nil, unquote(fst), array) else new(unquote(fst), unquote(snd), array) end else new(schema, unquote(name), array) end end |
.unquote(s) ⇒ Object
55 56 57 58 |
# File 'lib/piggly/dumper/qualified_type.rb', line 55 def self.unquote(s) return s if s.nil? s[/^"(.*)"$/, 1] || s end |
Instance Method Details
#==(other) ⇒ Object
88 89 90 |
# File 'lib/piggly/dumper/qualified_type.rb', line 88 def ==(other) self.to_s == other.to_s end |
#quote ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/piggly/dumper/qualified_type.rb', line 72 def quote if @schema '"' + @schema + '"."' + normalize(@name) + '"' + @array else '"' + normalize(@name) + '"' + @array end end |
#shorten ⇒ Object
68 69 70 |
# File 'lib/piggly/dumper/qualified_type.rb', line 68 def shorten self.class.new(nil, @name, @array) end |
#table? ⇒ Boolean
64 65 66 |
# File 'lib/piggly/dumper/qualified_type.rb', line 64 def table? false end |
#to_s ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/piggly/dumper/qualified_type.rb', line 80 def to_s unless [nil, "", "pg_catalog"].include?(@schema) @schema + "." + readable(@name) + @array else readable(@name) + @array end end |