Class: ActiveRecord::DatabaseViews::View

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord-database-views/view.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pathObject (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

#nameObject



17
18
19
# File 'lib/activerecord-database-views/view.rb', line 17

def name
  File.basename(path, '.sql')
end