Module: Rpub::HashDelegation

Defined in:
lib/rpub/hash_delegation.rb

Overview

Delegate missing methods to keys in a Hash atribute on the current object.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary (collapse)

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(m, *args, &block)



18
19
20
21
# File 'lib/rpub/hash_delegation.rb', line 18

def method_missing(m, *args, &block)
  return super unless respond_to? m
  delegated_hash.fetch m.to_s
end

Instance Method Details

- (Boolean) respond_to?(m)

Returns:

  • (Boolean)


14
15
16
# File 'lib/rpub/hash_delegation.rb', line 14

def respond_to?(m)
  super || delegated_hash.has_key?(m.to_s)
end