Class: Powncer::Event
Constant Summary
Constants inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Event
constructor
A new instance of Event.
Methods inherited from Note
ensure_send_to, find, #is_public?, #link, #recipients, #save, #sender, #type
Methods inherited from Base
extract_options, #id, instantiate, parse, #post, post, request, #request
Constructor Details
#initialize(options = {}) ⇒ Event
Returns a new instance of Event.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/powncer/event.rb', line 5 def initialize( = {}) raise RequirementMissing, "Event requires a name" unless [:name] raise RequirementMissing, "Event requires a location" unless [:location] raise RequirementMissing, "Event requires a date" unless [:date] raise InvalidFormat, "Event date should be formatted YYYY-MM-DD hh:mm" unless [:date].is_valid_date? super @attributes["name"] = [:name] @attributes["location"] = [:location] @attributes["date"] = [:date] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Powncer::Base
Class Method Details
.create(attributes) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/powncer/event.rb', line 26 def create(attributes) attributes.symbolize_keys! event = self.new(attributes) unless event.to.is_a?(Symbol) target_key = self.superclass.ensure_send_to(:friend, event.to) end url = "/send/event.#{self.superclass::FORMAT}" Event.instantiate post(url, {:to => target_key || event.to, :name => event.name, :location => event.location, :date => event.date}) end |