lib/speed_gun/config.rb in speed_gun-0.0.4 vs lib/speed_gun/config.rb in speed_gun-1.0.0.rc1

- old
+ new

@@ -1,59 +1,50 @@ +require 'hashie' require 'speed_gun' +require 'speed_gun/store/memory_store' -class SpeedGun::Config < Hash - def enable? - enable && enable_if.call - end +class SpeedGun::Config < Hashie::Dash + # @!attribute [rw] + # @return [Boolean] true if enabled speed gun + property :enable, default: true - def enable - fetch(:enable, true) - end + # @!attribute [rw] + # @return [Object, nil] logger of the speed gun + property :logger, default: nil - def enable_if - self[:enable_if] ||= -> { true } - end + # @!attribute [rw] + # @return [Array<Regexp>] paths of skip the speed gun + property :skip_paths, default: [] - def prefix - self[:prefix] ||= '/speed_gun' - end + # @!attribute [rw] + # @return [SpeedGun::Store] store of events and profiles + property :store, default: SpeedGun::Store::MemoryStore.new - def prefix_regexp - self[:prefix_regexp] ||= /^#{Regexp.escape(prefix)}/x - end + # @!attribute [rw] + # @return [Boolean] true if enable auto injection + property :auto_inject, default: true - def store - self[:store] ||= SpeedGun::Store::Memory.new + # @return [true] + def enable! + self[:enable] = true end - def auto_inject? - fetch(:auto_inject, true) + # @return [false] + def disable! + self[:enable] = false end - def backtrace_remove - self[:backtrace_remove] ||= '' + # @return [Boolean] true if enabled speed gun + def enabled? + !!enable end - def backtrace_includes - self[:backtrace_includes] ||= [] + # @return [Boolean] true if disabled speed gun + def disabled? + !enabled? end - def show_button? - fetch(:show_button, true) - end - - def no_include_jquery? - fetch(:no_include_jquery, false) - end - - def skip_paths - self[:skip_paths] ||= [/favicon/] - end - - def force_profile? - fetch(:force_profile, true) - end - - def authorize_proc - self[:authorize_proc] ||= ->(request) { true } + # @return [Boolean] true if enable auto injection + def auto_inject? + auto_inject end end