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, ListCommand, Migration, Railtie, VersionGenerator, View
Constant Summary
collapse
- VERSION =
"0.1.7"
Class Method Summary
collapse
Class Method Details
.bump(view_name) ⇒ Object
46
47
48
|
# File 'lib/monocle.rb', line 46
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
66
67
68
|
# File 'lib/monocle.rb', line 66
def configure
yield configuration if block_given?
end
|
.create(view_name) ⇒ Object
29
30
31
|
# File 'lib/monocle.rb', line 29
def create(view_name)
fetch(view_name).create
end
|
.drop(view_name) ⇒ Object
25
26
27
|
# File 'lib/monocle.rb', line 25
def drop(view_name)
fetch(view_name).drop
end
|
.fetch(view_name) ⇒ Object
84
85
86
87
|
# File 'lib/monocle.rb', line 84
def fetch(view_name)
view_name = symbolize_name(view_name)
list.fetch(view_name)
end
|
.gem_root ⇒ Object
79
80
81
82
|
# File 'lib/monocle.rb', line 79
def gem_root
File.expand_path(File.dirname(__dir__))
end
|
.migrate ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/monocle.rb', line 37
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
50
51
52
|
# File 'lib/monocle.rb', line 50
def refresh(view_name, concurrently: false)
fetch(view_name).refresh concurrently: concurrently
end
|
.refresh_all ⇒ Object
54
55
56
57
58
59
|
# File 'lib/monocle.rb', line 54
def refresh_all
list.each do |key, view|
logger.info "Refreshing view #{key}..."
view.refresh end
end
|
.root ⇒ Object
74
75
76
77
|
# File 'lib/monocle.rb', line 74
def root
File.expand_path(Dir.pwd)
end
|
.views_path ⇒ Object
70
71
72
|
# File 'lib/monocle.rb', line 70
def views_path
File.join(root, path_to_views)
end
|