Class: Vp::Pears::VpTheme
- Inherits:
-
Pears::Provider::LocalFile
- Object
- Pears::Provider::LocalFile
- Vp::Pears::VpTheme
- Defined in:
- lib/vp/pears/vp_theme.rb
Defined Under Namespace
Classes: InvalidVpTheme
Constant Summary collapse
- THEMES =
Get all
Dir[ "#{__FILE__}".split('/') .slice(0..-4) .join('/') .+('/themes/*') ]
- MAP =
Hash[ THEMES.map do |fil| fil.split('/') .last .delete_suffix('.yml') end.zip(THEMES) ].with_indifferent_access.freeze
Instance Method Summary collapse
-
#initialize(name, on_failure: :raise) ⇒ VpTheme
constructor
A new instance of VpTheme.
Constructor Details
#initialize(name, on_failure: :raise) ⇒ VpTheme
Returns a new instance of VpTheme.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vp/pears/vp_theme.rb', line 23 def initialize(name, on_failure: :raise) file = MAP[name&.downcase] raise InvalidVpTheme.new(name) unless file.present? super(file, on_failure: on_failure) rescue InvalidVpTheme => e if on_failure == :null @data = {} else raise e end end |