lib/lookbook/panels.rb in lookbook-1.0.8 vs lib/lookbook/panels.rb in lookbook-1.1.0
- old
+ new
@@ -1,15 +1,25 @@
module Lookbook
module Panels
- def define_panel(name, opts = {})
- Lookbook.config.define_inspector_panel(name, opts)
+ def define_panel(name, *args)
+ Lookbook.config.define_inspector_panel(name, extract_opts(args))
end
- def amend_panel(name, opts = {})
- Lookbook.amend_inspector_panel(name, opts)
+ def amend_panel(name, *args)
+ Lookbook.amend_inspector_panel(name, extract_opts(args))
end
def remove_panel(name)
Lookbook.remove_inspector_panel(name)
+ end
+
+ def extract_opts(args)
+ if args.many?
+ opts = args[1]
+ opts[:partial] = args[0]
+ opts
+ elsif args.any?
+ args[0].is_a?(String) ? {partial: args[0]} : args[0]
+ end
end
end
end