Module: Rack::Campfire::Coercion
- Included in:
- Rack::Campfire
- Defined in:
- lib/rack/campfire/coercion.rb
Instance Method Summary collapse
Instance Method Details
#coerce_body(body) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/rack/campfire/coercion.rb', line 25 def coerce_body(body) if body.respond_to? :body body.body else [body].join("\n") end end |
#coerce_rooms(rooms) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rack/campfire/coercion.rb', line 3 def coerce_rooms(rooms) case rooms when :all @campfire.rooms when nil [@campfire.rooms.first] when Integer [@campfire.find_room_by_id(rooms)] when String [@campfire.find_room_by_name(rooms)] when Array rooms.inject([]) do |array, room| case room when Integer array += @campfire.find_room_by_id(room) when String array += @campfire.find_room_by_name(room) end end end end |