Class: Macker::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/macker/config.rb

Overview

Configuration class

Instance Method Summary collapse

Constructor Details

#initializeOpenStruct

Initialization with default configuration.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/macker/config.rb', line 8

def initialize
  @config = OpenStruct.new(
    # Full URL of OUI text file
    oui_full_url:    'http://standards-oui.ieee.org/oui.txt',
    # A common user agent
    user_agent:      'Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0',
    # Will expire the vendors in one day
    ttl_in_seconds:  86_400,
    # Can be a string, pathname or proc
    cache:           File.expand_path(File.dirname(__FILE__) + '/../../data/oui_*.txt'),
    # Expiration can be checked manually
    auto_expire:     true,
    # Stale can be checked manually
    auto_stale:      true
  )
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Send missing methods to the OpenStruct configuration.

Parameters:

  • method (String)

    the missing method name

  • *args (Array)

    list of arguments of the missing method

Returns:

  • (Object)

    a configuration parameter



30
31
32
# File 'lib/macker/config.rb', line 30

def method_missing(method, *args, &block)
  @config.send(method, *args, &block)
end