Permalink
Browse files

Support for false/nil options accessed through method_missing. Nonfun…

…ctional paste disabling for campfire.
  • Loading branch information...
1 parent 0fadf58 commit c5d8a6764f832a71592ba62cf8c49a6b716a3f84 @jqr jqr committed Aug 29, 2008
Showing with 9 additions and 5 deletions.
  1. +4 −4 lib/snitch/service.rb
  2. +5 −1 lib/snitch/services/campfire.rb
View
@@ -7,18 +7,18 @@ def self.new_from_name(s, attributes)
end
def initialize(attributes)
- self.attributes = default_options.merge(attributes || {})
+ self.attributes = default_options.merge(attributes || {}).symbolize_keys
end
def default_options
{ :message_length => :long }
end
def method_missing(method, *args, &block)
- if method.to_s =~ /=$/
- self.attributes[method.to_s.chop] = args[0]
+ if attributes.include?(method)
+ attributes[method]
else
- attributes[method.to_s] || attributes[method] || super
+ super
end
end
end
@@ -9,8 +9,12 @@ def connection
connection.find_or_create_room_by_name(room)
end
+ def default_options
+ super.merge(:paste => true)
+ end
+
def tattle(message)
- connection.paste(message)
+ connection.speak(message, :paste => paste)
end
end
end

0 comments on commit c5d8a67

Please sign in to comment.