Class: FCC::Station::ResultDelegate

Inherits:
Object
  • Object
show all
Defined in:
lib/fcc/station/result_delegate.rb

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ ResultDelegate

Returns a new instance of ResultDelegate.



7
8
9
# File 'lib/fcc/station/result_delegate.rb', line 7

def initialize(result)
  @result = result
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fcc/station/result_delegate.rb', line 11

def method_missing(m, *args, &block)
  if @result
    matched_key = @result.keys.detect { |d| m.to_s == d.to_s } || @result.keys.detect { |d| m.to_s == d.underscore.to_s }

    if matched_key
      @result[matched_key]
    else
      super
    end
  end
end