Class: Powncer::Event

Inherits:
Note show all
Defined in:
lib/powncer/event.rb

Constant Summary

Constants inherited from Base

Base::FORMAT

Class Method Summary collapse

Instance Method Summary collapse

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.

Raises:



5
6
7
8
9
10
11
12
13
14
# File 'lib/powncer/event.rb', line 5

def initialize(options = {})
  raise RequirementMissing, "Event requires a name" unless options[:name]
  raise RequirementMissing, "Event requires a location" unless options[:location]
  raise RequirementMissing, "Event requires a date" unless options[:date]
  raise InvalidFormat, "Event date should be formatted YYYY-MM-DD hh:mm" unless options[:date].is_valid_date?
  super
  @attributes["name"] = options[:name]
  @attributes["location"] = options[:location]
  @attributes["date"] = options[: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