Module: Maglev::Page::PathConcern

Extended by:
ActiveSupport::Concern
Included in:
Maglev::Page
Defined in:
app/models/maglev/page/path_concern.rb

Overview

rubocop:disable Style/ClassAndModuleChildren

Instance Method Summary collapse

Instance Method Details

#current_pathObject



40
41
42
43
44
# File 'app/models/maglev/page/path_concern.rb', line 40

def current_path
  locale = Maglev::I18n.current_locale.to_sym
  @memoized_paths ||= {}
  @memoized_paths[locale] ||= paths.canonical.find_or_initialize_by(locale: locale, canonical: true)
end

#default_pathObject



21
22
23
# File 'app/models/maglev/page/path_concern.rb', line 21

def default_path
  @default_path ||= paths.find_by(locale: Maglev::I18n.default_locale)&.value
end

#disable_spawn_redirectionObject



50
51
52
# File 'app/models/maglev/page/path_concern.rb', line 50

def disable_spawn_redirection
  @disable_spawn_redirection = true
end

#pathObject



25
26
27
# File 'app/models/maglev/page/path_concern.rb', line 25

def path
  current_path.value
end

#path=(value) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'app/models/maglev/page/path_concern.rb', line 29

def path=(value)
  unless value.respond_to?(:each_pair)
    current_path.value = value
    return
  end

  value.each_pair do |locale, new_path|
    Maglev::I18n.with_locale(locale) { self.path = new_path }
  end
end

#path_hashObject



46
47
48
# File 'app/models/maglev/page/path_concern.rb', line 46

def path_hash
  paths.build_hash
end

#spawn_redirection_disabled?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'app/models/maglev/page/path_concern.rb', line 54

def spawn_redirection_disabled?
  !!@disable_spawn_redirection
end