Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Make config.adapter a real Lita::Config subclass.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmycuadra committed Oct 10, 2014
1 parent 19ecbc0 commit d4b6281
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/lita/default_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,30 @@ def adapters_config

def add_adapter_attribute(config)
config.singleton_class.class_exec { attr_accessor :adapter }
config.adapter = Object.new
config.adapter.singleton_class.class_exec do
config.adapter = Class.new(Config) do
def []=(key, value)
public_send("#{key}=", value)
deprecation_warning

super
end

def [](key)
public_send(key)
deprecation_warning

super
end

def method_missing(name, *args)
deprecation_warning

super
end

def deprecation_warning
Lita.logger.warn(I18n.t("lita.config.adapter_deprecated"))
name_string = name.to_s
if name_string.chomp!("=")
instance_variable_set("@#{name_string}", args.first)
else
instance_variable_get("@#{name_string}")
end
end
end
private :deprecation_warning
end.new
end

def add_struct_access_to_redis(redis)
Expand Down

0 comments on commit d4b6281

Please sign in to comment.