Class: ActiveRecord::DatabaseViews::View
- Inherits:
-
Object
- Object
- ActiveRecord::DatabaseViews::View
- Defined in:
- lib/activerecord-database-views/view.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #drop! ⇒ Object
-
#initialize(path) ⇒ View
constructor
A new instance of View.
- #load! ⇒ Object
- #name ⇒ Object
Constructor Details
#initialize(path) ⇒ View
Returns a new instance of View.
5 6 7 |
# File 'lib/activerecord-database-views/view.rb', line 5 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/activerecord-database-views/view.rb', line 3 def path @path end |
Instance Method Details
#drop! ⇒ Object
9 10 11 |
# File 'lib/activerecord-database-views/view.rb', line 9 def drop! call_sql!("DROP VIEW IF EXISTS #{name} CASCADE;") end |
#load! ⇒ Object
13 14 15 |
# File 'lib/activerecord-database-views/view.rb', line 13 def load! call_sql!("CREATE OR REPLACE VIEW #{name} AS #{sql};") end |
#name ⇒ Object
17 18 19 |
# File 'lib/activerecord-database-views/view.rb', line 17 def name File.basename(path, '.sql') end |