I am building a sinatra app that will use Highrise CRM gem to access Highrise data. This gem is based on ActiveResource class. I want to set site, user fields for every request.
While defining method with define_method you can specify its arguments passing them as arguments to the block and not to define_method itself. So you can define setter method like that:
define_method("#{attr}=") do |val|
Thread.current["active_resource.#{attr}"] = val
end