Skip to content

Instantly share code, notes, and snippets.

@cfeduke
Created March 23, 2011 16:49
Show Gist options
  • Save cfeduke/883453 to your computer and use it in GitHub Desktop.
Save cfeduke/883453 to your computer and use it in GitHub Desktop.
Internal weather message for sponsorship stuff
module Protocol
class WeatherServiceRequestMessage
include ActiveModel::Serialization
attr_accessor :client, :version, :format, :payload, :instructions
REQUIRED_PHONE_PROFILE_IDS = ["0", "9", "13"].freeze
def initialize
@client = Client::NODE_SMASHER
@version = Version::CURRENT_VERSION
@format = Format::DEFAULT
@payload = Payload.new(:weather)
@instructions = { }
@instructions.instance_eval do
def to_key_value
abbr_instructions = { }
self.each do |k,v|
if REQUIRED_PHONE_PROFILE_IDS.include? k
abbr_instructions[k] = v.map { |i| i.id }
end
end
"instructions: " + abbr_instructions.to_json
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment