Module: Mwc::Utils::HashAccessor

Defined in:
lib/mwc/utils/hash_accessor.rb

Overview

Provide Hash-like accessor

Instance Method Summary collapse

Instance Method Details

#[](name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Hash-like getter

Parameters:

  • name (String|Symbol)

    the option name

Since:

  • 0.3.0



13
14
15
16
17
# File 'lib/mwc/utils/hash_accessor.rb', line 13

def [](name)
  return unless respond_to?(name)

  send(name)
end

#[]=(name, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Hash-like setter

Parameters:

  • name (String|Symbol)

    the option name

  • value (Object)

    the option value

Since:

  • 0.3.0



26
27
28
29
30
# File 'lib/mwc/utils/hash_accessor.rb', line 26

def []=(name, value)
  return unless respond_to?("#{name}=")

  send("#{name}=", value)
end