Class: OptionsHash

Inherits:
Object
  • Object
show all
Defined in:
lib/options-hash.rb

Overview

Options hash which allows defiying the default values and access to items as to properties.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ OptionsHash

Constructor.

Parameters:

  • options (Hash) (defaults to: {})

    options data



37
38
39
# File 'lib/options-hash.rb', line 37

def initialize(options = {})
    @options = options
end

Class Method Details

.get(options = {}) ⇒ OptionsHash

Assigns the options data.

Parameters:

  • options (Hash) (defaults to: {})

    options data

Returns:



28
29
30
# File 'lib/options-hash.rb', line 28

def self.get(options = {})
    self::new(options)
end

Instance Method Details

#[](defaults = {}) ⇒ Hashie::Mash

Assigns the default values.

Parameters:

  • defaults (Hash) (defaults to: {})

    defaults data

Returns:

  • (Hashie::Mash)

    object-like accessible pseudo-hash



48
49
50
# File 'lib/options-hash.rb', line 48

def [](defaults = {})
    Hashie::Mash::new(defaults.merge(@options))
end