Class: ODDB::Html::Util::KnowItAll

Inherits:
Object
  • Object
show all
Defined in:
lib/oddb/html/util/know_it_all.rb

Instance Method Summary collapse

Constructor Details

#initialize(delegate, values = {}) ⇒ KnowItAll

Returns a new instance of KnowItAll.



8
9
10
11
# File 'lib/oddb/html/util/know_it_all.rb', line 8

def initialize delegate, values={}
  @delegate = delegate
  @values = values
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



15
16
17
18
19
20
21
# File 'lib/oddb/html/util/know_it_all.rb', line 15

def method_missing name, *args, &block
  if @delegate.respond_to? name
    @delegate.send name, *args, &block
  else
    @values[name]
  end
end

Instance Method Details

#is_a?(mod) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/oddb/html/util/know_it_all.rb', line 12

def is_a? mod
  @delegate.is_a?(mod) || super
end

#respond_to?(name) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/oddb/html/util/know_it_all.rb', line 22

def respond_to? name
  @delegate.respond_to?(name) || @values.include?(name)
end