Module: Monocle
- Defined in:
- lib/monocle/view.rb,
lib/monocle.rb,
lib/monocle/railtie.rb,
lib/monocle/version.rb,
lib/monocle/migration.rb,
lib/monocle/list_command.rb,
lib/monocle/configuration.rb,
lib/monocle/version_generator.rb
Overview
An in-memory representation of the view
Defined Under Namespace
Modules: Generators
Classes: BumpCommand, Configuration, DropCommand, ListCommand, Migration, Railtie, VersionGenerator, View
Constant Summary
collapse
- VERSION =
"0.2.3"
Class Method Summary
collapse
Class Method Details
.bump(view_name) ⇒ Object
47
48
49
|
# File 'lib/monocle.rb', line 47
def bump(view_name)
BumpCommand.new(fetch(view_name)).call
end
|
Enables you to configure things in a block, i.e Monocle.configure do |config|
config.logger = MyLogger.new
config.path_to_views = "my/different/path/to/my/sql/files"
end
71
72
73
|
# File 'lib/monocle.rb', line 71
def configure
yield configuration if block_given?
end
|
.create(view_name) ⇒ Object
30
31
32
|
# File 'lib/monocle.rb', line 30
def create(view_name)
fetch(view_name).create
end
|
.drop(view_name) ⇒ Object
26
27
28
|
# File 'lib/monocle.rb', line 26
def drop(view_name)
fetch(view_name).drop
end
|
.fetch(view_name) ⇒ Object
89
90
91
92
|
# File 'lib/monocle.rb', line 89
def fetch(view_name)
view_name = symbolize_name(view_name)
list.fetch(view_name)
end
|
.gem_root ⇒ Object
84
85
86
87
|
# File 'lib/monocle.rb', line 84
def gem_root
File.expand_path(File.dirname(__dir__))
end
|
.migrate ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/monocle.rb', line 38
def migrate
logger.info "Starting materialized views migrations..."
list.each do |key, view|
logger.debug "Checking if #{key} is up to date..."
view.migrate
end
logger.info "All done!"
end
|
.refresh(view_name, concurrently: false) ⇒ Object
55
56
57
|
# File 'lib/monocle.rb', line 55
def refresh(view_name, concurrently: false)
fetch(view_name).refresh concurrently: concurrently
end
|
.refresh_all ⇒ Object
59
60
61
62
63
64
|
# File 'lib/monocle.rb', line 59
def refresh_all
list.each do |key, view|
logger.info "Refreshing view #{key}..."
view.refresh end
end
|
.root ⇒ Object
79
80
81
82
|
# File 'lib/monocle.rb', line 79
def root
File.expand_path(Dir.pwd)
end
|
.views_path ⇒ Object
75
76
77
|
# File 'lib/monocle.rb', line 75
def views_path
File.join(root, path_to_views)
end
|