lib/meibo.rb in meibo-0.12.0 vs lib/meibo.rb in meibo-0.13.0

- old
+ new

@@ -13,9 +13,27 @@ CSV_ENCODING = 'UTF-8' ENUM_EXT_PATTERN = /\Aext:[a-zA-Z0-9\.\-_]+\z/ class << self attr_accessor :default_profile + + def current_roster + thread_local_data[:roster] + end + + def with_roster(roster) + orig_roster = thread_local_data[:roster] + thread_local_data[:roster] = roster + yield + ensure + thread_local_data[:roster] = orig_roster + end + + private + + def thread_local_data + Thread.current[:__meibo] ||= {} + end end end loader.eager_load