lib/vp/pears/vp_theme.rb in vp-themes-0.1.1 vs lib/vp/pears/vp_theme.rb in vp-themes-0.1.2
- old
+ new
@@ -1,10 +1,12 @@
module Vp
module Pears
class VpTheme < ::Pears::Provider::LocalFile
class InvalidVpTheme < StandardError; end;
+
+ # Get all
THEMES = Dir[
"#{__FILE__}".split('/')
.slice(0..-4)
.join('/')
.+('/themes/*')
@@ -21,9 +23,15 @@
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
end
::Pears::Provider::Builder.enable_provider VpTheme
end