Class: Wallaby::View::CustomPrefixes
- Inherits:
-
Object
- Object
- Wallaby::View::CustomPrefixes
- Defined in:
- lib/wallaby/view/custom_prefixes.rb
Overview
Custom prefix builder to add more lookup prefix paths to given #prefixes.
Instance Attribute Summary collapse
-
#action_name ⇒ String
readonly
Action name to be added.
-
#options ⇒ Hash
readonly
Options for extending the given prefixes.
-
#prefixes ⇒ Array<String>
readonly
Base prefixes to extend.
-
#themes ⇒ Array<Hash>
readonly
Themes to be inserted.
Class Method Summary collapse
-
.execute(prefixes:, action_name:, themes: nil, options: nil, &block) ⇒ Array<String>
Extend given prefixes with action name and theme name.
Instance Method Summary collapse
-
#execute(&block) ⇒ Array<String>
Extend given prefixes with action name and theme name.
-
#initialize(prefixes:, action_name:, themes:, options:) ⇒ CustomPrefixes
constructor
Create the instance.
Constructor Details
#initialize(prefixes:, action_name:, themes:, options:) ⇒ CustomPrefixes
Create the instance
86 87 88 89 90 91 |
# File 'lib/wallaby/view/custom_prefixes.rb', line 86 def initialize(prefixes:, action_name:, themes:, options:) @prefixes = prefixes @action_name = action_name @themes = themes @options = ( || {}).with_indifferent_access end |
Instance Attribute Details
#action_name ⇒ String (readonly)
Action name to be added
16 17 18 |
# File 'lib/wallaby/view/custom_prefixes.rb', line 16 def action_name @action_name end |
#options ⇒ Hash (readonly)
Options for extending the given prefixes
27 28 29 |
# File 'lib/wallaby/view/custom_prefixes.rb', line 27 def @options end |
#prefixes ⇒ Array<String> (readonly)
Base prefixes to extend
11 12 13 |
# File 'lib/wallaby/view/custom_prefixes.rb', line 11 def prefixes @prefixes end |
#themes ⇒ Array<Hash> (readonly)
Themes to be inserted
22 23 24 |
# File 'lib/wallaby/view/custom_prefixes.rb', line 22 def themes @themes end |
Class Method Details
.execute(prefixes:, action_name:, themes: nil, options: nil, &block) ⇒ Array<String>
Extend given prefixes with action name and theme name
72 73 74 75 76 77 78 79 |
# File 'lib/wallaby/view/custom_prefixes.rb', line 72 def self.execute( prefixes:, action_name:, themes: nil, options: nil, &block ) new( prefixes: prefixes, action_name: action_name, themes: themes, options: ).execute(&block) end |
Instance Method Details
#execute(&block) ⇒ Array<String>
Extend given prefixes with action name and theme name
95 96 97 98 99 100 101 |
# File 'lib/wallaby/view/custom_prefixes.rb', line 95 def execute(&block) new_prefixes(&block).each_with_object([]) do |prefix, array| # Extend the prefix with actions actions.each { |action| array << "#{prefix}/#{action}" } array << prefix end end |