Class: HashWrapper

Inherits:
Object
  • Object
show all
Defined in:
app/models/list_export.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ HashWrapper

Returns a new instance of HashWrapper.



285
286
287
# File 'app/models/list_export.rb', line 285

def initialize(hash)
  @hash = hash
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

This is a workaround for the to_xls gem, which requires to access the attributes by method in order to write the columns in the correct order.



292
293
294
# File 'app/models/list_export.rb', line 292

def method_missing(method_name, *args, &block)  
  @hash[method_name] || @hash[method_name.to_sym]
end