Class: Co2Filter::HashWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/co2_filter/hash_wrapper.rb

Direct Known Subclasses

ContentBased::UserProfile, RatingSet, Results

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ HashWrapper

Returns a new instance of HashWrapper.



2
3
4
# File 'lib/co2_filter/hash_wrapper.rb', line 2

def initialize(data)
  @data = data.to_hash
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



6
7
8
9
10
11
12
# File 'lib/co2_filter/hash_wrapper.rb', line 6

def method_missing(method, *args, &block)
  if [:keys, :values, :length, :size, :"[]", :"[]=", :each, :merge]
    @data.send(method, *args, &block)
  else
    super(method, *args, &block)
  end
end

Instance Method Details

#to_hashObject



14
15
16
# File 'lib/co2_filter/hash_wrapper.rb', line 14

def to_hash
  @data
end