Sha256: 2269285b74cfb8624ace8be5d173c4f4ed52dbdfa7682ed7b2d5ba9aeab1ad96
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
module Merb class Inspector module Helper def inspect(*args) return h(super()) if args.blank? object = args.shift options = args.shift || {} unless options.is_a?(Hash) action = options.to_s options = args.shift || {} options[:action] = action end options[:action] ||= :show options[:level] ||= 1 options[:max_level] ||= 3 # validate keys valid_keys = [:action, :level, :max_level, :only, :except, :columns, :lead] unknown_keys = options.keys - valid_keys if !unknown_keys.blank? return h("[INSPECTOR ERROR] Unknown key(s): %s" % unknown_keys.inspect) end inspector_class = BasicInspector if options[:level] >= options[:max_level] inspector_class ||= Manager.lookup(object) || Merb::Inspector.default inspector = inspector_class.new(Merb::Request.new({})) if inspector.respond_to?(options[:action]) inspector.send options[:action], object, options else message = "%s doesn't recognize '%s' action" % [inspector.class, options[:action]] raise Merb::Inspector::ActionNotFound, message end end end end end class Merb::Controller include Merb::Inspector::Helper end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
maiha-merb_inspector-0.3.2 | lib/merb_inspector/helper.rb |
merb_inspector-0.3.2 | lib/merb_inspector/helper.rb |