Class: PgHaMigrations::Extension
- Inherits:
-
Object
- Object
- PgHaMigrations::Extension
- Defined in:
- lib/pg_ha_migrations/extension.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(name) ⇒ Extension
constructor
A new instance of Extension.
- #installed? ⇒ Boolean
- #major_version ⇒ Object
- #quoted_schema ⇒ Object
Constructor Details
#initialize(name) ⇒ Extension
Returns a new instance of Extension.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/pg_ha_migrations/extension.rb', line 5 def initialize(name) @name = name @schema, @version = ActiveRecord::Base.connection.select_rows(<<~SQL).first SELECT nspname, extversion FROM pg_namespace JOIN pg_extension ON pg_namespace.oid = pg_extension.extnamespace WHERE pg_extension.extname = #{ActiveRecord::Base.connection.quote(name)} LIMIT 1 SQL end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/pg_ha_migrations/extension.rb', line 3 def name @name end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
3 4 5 |
# File 'lib/pg_ha_migrations/extension.rb', line 3 def schema @schema end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
3 4 5 |
# File 'lib/pg_ha_migrations/extension.rb', line 3 def version @version end |
Instance Method Details
#installed? ⇒ Boolean
31 32 33 |
# File 'lib/pg_ha_migrations/extension.rb', line 31 def installed? !!schema && !!version end |
#major_version ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/pg_ha_migrations/extension.rb', line 23 def major_version return unless version Gem::Version.new(version) .segments .first end |
#quoted_schema ⇒ Object
17 18 19 20 21 |
# File 'lib/pg_ha_migrations/extension.rb', line 17 def quoted_schema return unless schema PG::Connection.quote_ident(schema) end |