Class: Ponytail::Schema
- Inherits:
-
Object
- Object
- Ponytail::Schema
- Includes:
- ActiveModel::Model
- Defined in:
- lib/ponytail/schema.rb
Instance Attribute Summary collapse
-
#tables ⇒ Object
Returns the value of attribute tables.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #as_json(attrs) ⇒ Object
-
#initialize(params = {}) ⇒ Schema
constructor
A new instance of Schema.
- #update(attrs) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Schema
6 7 8 9 |
# File 'lib/ponytail/schema.rb', line 6 def initialize(params={}) super(params) @version = ActiveRecord::Migrator.current_version end |
Instance Attribute Details
#tables ⇒ Object
Returns the value of attribute tables.
4 5 6 |
# File 'lib/ponytail/schema.rb', line 4 def tables @tables end |
#version ⇒ Object
Returns the value of attribute version.
4 5 6 |
# File 'lib/ponytail/schema.rb', line 4 def version @version end |
Instance Method Details
#as_json(attrs) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/ponytail/schema.rb', line 30 def as_json(attrs) { version: version, tables: tables } end |
#update(attrs) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/ponytail/schema.rb', line 21 def update(attrs) @version = attrs["version"].to_i if Ponytail.config.update_schema? ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, @version) else false end end |