lib/lita/adapters/campfire.rb in lita-campfire-0.2.1 vs lib/lita/adapters/campfire.rb in lita-campfire-0.3.0
- old
+ new
@@ -1,24 +1,30 @@
module Lita
module Adapters
class Campfire < Adapter
- require_configs :subdomain, :apikey, :rooms
- OPTIONAL_CONFIG_OPTIONS = %i(debug tinder_options)
+ namespace 'campfire'
+ config :subdomain, type: String, required: true
+ config :apikey, type: String, required: true
+ config :rooms, type: Array, required: true
+
+ config :debug, type: [TrueClass, FalseClass], default: false
+ config :tinder_options, type: Hash, default: {}
+
attr_reader :connector
def initialize(robot)
super
options = {
subdomain: config.subdomain,
apikey: config.apikey,
rooms: rooms,
+ debug: config.debug,
+ tinder_options: config.tinder_options
}
- options.merge!(optional_config_options)
-
@connector = Connector.new(
robot,
options
)
end
@@ -44,27 +50,20 @@
end
private
def config
- Lita.config.adapter
+ Lita.config.adapters.campfire
end
def rooms
Array(config.rooms)
end
def disconnect
connector.disconnect
end
-
- def optional_config_options
- OPTIONAL_CONFIG_OPTIONS.each_with_object({}) do |config_option, options|
- config_option_value = config.public_send(config_option)
- options[config_option] = config_option_value if config_option_value
- end
- end
end
Lita.register_adapter(:campfire, Campfire)
end
-end
\ No newline at end of file
+end