Module: EffectiveRegions

Includes:
EffectiveGem
Defined in:
lib/effective_regions.rb,
lib/effective_regions/engine.rb,
lib/effective_regions/version.rb

Defined Under Namespace

Classes: Engine

Constant Summary collapse

VERSION =
'1.12.0'.freeze

Class Method Summary collapse

Class Method Details

.config_keysObject



8
9
10
# File 'lib/effective_regions.rb', line 8

def self.config_keys
  [:regions_table_name, :ck_assets_table_name, :before_save_method]
end

.read_snippetsObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/effective_regions.rb', line 26

def self.read_snippets
  # Reversing here so the app's templates folder has precedence.
  files = ApplicationController.view_paths.map { |path| Dir["#{path}/effective/snippets/**"] }.flatten.reverse

  files.map do |file|
    snippet = File.basename(file)
    snippet = snippet[1...snippet.index('.') || snippet.length] # remove the _ and .html.haml

    "Effective::Snippets::#{snippet.try(:classify)}".constantize.new()
  end

end

.read_templatesObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/effective_regions.rb', line 39

def self.read_templates
  # Reversing here so the app's templates folder has precedence.
  files = ApplicationController.view_paths.map { |path| Dir["#{path}/effective/templates/**"] }.flatten.reverse

  files.map do |file|
    template = File.basename(file)
    template = template[1...template.index('.') || template.length] # remove the _ and .html.haml

    "Effective::Templates::#{template.try(:classify)}".constantize.new()
  end
end

.snippetsObject

Returns a Snippet.new() for every class in the /app/effective/snippets/* directory



15
16
17
# File 'lib/effective_regions.rb', line 15

def self.snippets
  Rails.env.development? ? read_snippets : (@@snippets ||= read_snippets)
end

.templatesObject

Returns a Template.new() for every class in the /app/effective/templates/* directory



20
21
22
# File 'lib/effective_regions.rb', line 20

def self.templates
  Rails.env.development? ? read_templates : (@@templates ||= read_templates)
end