Class: MatViews::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/mat_views/engine.rb

Overview

Rails Engine for MatViews.

This engine encapsulates all functionality related to materialised views, including:

  • Defining materialised view definitions

  • Creating and refreshing views

  • Managing background jobs for refresh/create/delete

By isolating the namespace, it ensures that routes, models, and helpers do not conflict with the host application.

Examples:

Mounting the engine in a Rails application

# config/routes.rb
Rails.application.routes.draw do
  mount MatViews::Engine => "/mat_views"
end

Class Method Summary collapse

Class Method Details

.available_localesObject



67
68
69
# File 'lib/mat_views/engine.rb', line 67

def self.available_locales
  @available_locales ||= locale_code_mapping.keys.freeze
end

.bug_tracker_uriObject



78
# File 'lib/mat_views/engine.rb', line 78

def self.bug_tracker_uri = loaded_spec&.&.[]('bug_tracker_uri')

.company_nameObject



76
# File 'lib/mat_views/engine.rb', line 76

def self.company_name = 'Codevedas Inc.'

.default_localeObject



71
# File 'lib/mat_views/engine.rb', line 71

def self.default_locale = :en

.documentation_uriObject



77
# File 'lib/mat_views/engine.rb', line 77

def self.documentation_uri = loaded_spec&.&.[]('documentation_uri')

.loaded_specObject



72
# File 'lib/mat_views/engine.rb', line 72

def self.loaded_spec = Gem.loaded_specs['mat_views']

.locale_code_mappingObject



56
57
58
59
60
61
62
63
64
65
# File 'lib/mat_views/engine.rb', line 56

def self.locale_code_mapping
  @locale_code_mapping ||= begin
    mappings = Dir[root.join('config', 'locales', '*.yml')].map.to_h do |file|
      code = File.basename(file, '.yml').to_sym
      name = I18n.t('i18n.name', locale: code)
      [code, name]
    end
    mappings.sort_by { |code, _name| code.to_s }.to_h
  end
end

.project_homepageObject



75
# File 'lib/mat_views/engine.rb', line 75

def self.project_homepage = loaded_spec&.homepage

.project_nameObject



73
# File 'lib/mat_views/engine.rb', line 73

def self.project_name = loaded_spec&.name

.project_versionObject



74
# File 'lib/mat_views/engine.rb', line 74

def self.project_version = MatViews::VERSION

.rubygems_uriObject



80
# File 'lib/mat_views/engine.rb', line 80

def self.rubygems_uri = loaded_spec&.&.[]('rubygems_uri')

.support_uriObject



79
# File 'lib/mat_views/engine.rb', line 79

def self.support_uri = loaded_spec&.&.[]('support_uri')