lib/tamashii/agent/config.rb in tamashii-agent-0.3.0 vs lib/tamashii/agent/config.rb in tamashii-agent-0.3.1

- old
+ new

@@ -3,16 +3,15 @@ module Tamashii module Agent class Config < Tamashii::Config AUTH_TYPES = [:none, :token] + register :default_components, {networking: {class_name: :Networking, options: {}}} register :connection_timeout, 3 register :localtime, "+08:00" - register :lcd_path, '/dev/i2c-1' - register :lcd_address, 0x27 register :lcd_animation_delay, 1 def auth_type(type = nil) return @auth_type ||= :none if type.nil? @@ -34,9 +33,21 @@ [:use_ssl, :host, :port, :entry_point].each do |method_name| define_method(method_name) do |*args| Tamashii::Client.config.send(method_name, *args) end + end + + def add_component(name, class_name, options = {}, &block) + self.components[name] = {class_name: class_name, options: options, block: block} + end + + def remove_component(name) + self.components.delete(name) + end + + def components + @components ||= self.default_components.clone end end end end