Module: Rack::WebProfiler::Collector::DSL::ClassMethods

Defined in:
lib/rack/web_profiler/collector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



20
21
22
# File 'lib/rack/web_profiler/collector.rb', line 20

def definition
  @definition
end

Instance Method Details

#collect(&block) ⇒ Object



41
# File 'lib/rack/web_profiler/collector.rb', line 41

def collect(&block); definition.collect = block; end

#icon(icon = nil) ⇒ Object

Set the icon of the Rack::WebProfiler::Collector.

Parameters:

  • icon (String, nil) (defaults to: nil)


25
# File 'lib/rack/web_profiler/collector.rb', line 25

def icon(icon = nil); definition.icon = icon; end

#identifier(identifier = nil) ⇒ Object

Set the identifier of the Rack::WebProfiler::Collector.

Parameters:

  • identifier (String, nil) (defaults to: nil)


30
# File 'lib/rack/web_profiler/collector.rb', line 30

def identifier(identifier = nil); definition.identifier = identifier; end

#is_enabled?(is_enabled = true) ⇒ Boolean

Tell if the Rack::WebProfiler::Collector is enabled.

Parameters:

  • is_enabled (Boolean, Block) (defaults to: true)

Returns:

  • (Boolean)


55
56
57
58
# File 'lib/rack/web_profiler/collector.rb', line 55

def is_enabled?(is_enabled = true)
  definition.is_enabled = Proc.new if block_given?
  definition.is_enabled = is_enabled
end

#label(label = nil) ⇒ Object

Set the label of the Rack::WebProfiler::Collector.

Parameters:

  • label (String, nil) (defaults to: nil)


35
# File 'lib/rack/web_profiler/collector.rb', line 35

def label(label = nil); definition.label = label; end

#position(position = nil) ⇒ Object



38
# File 'lib/rack/web_profiler/collector.rb', line 38

def position(position = nil); definition.position = position.to_i; end

#template(template = nil, type: :file) ⇒ Object

Set the template of the Rack::WebProfiler::Collector.

Parameters:

  • template (String, nil) (defaults to: nil)
  • type (Hash) (defaults to: :file)

    a customizable set of options

Options Hash (type:):

  • :file (Symbol)

    or :DATA



47
48
49
50
# File 'lib/rack/web_profiler/collector.rb', line 47

def template(template = nil, type: :file)
  template = get_data_contents(template) if type == :DATA
  definition.template = template
end