Class: Powncer::Link

Inherits:
Note show all
Defined in:
lib/powncer/link.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 = {}) ⇒ Link

Returns a new instance of Link.

Raises:



5
6
7
8
9
10
# File 'lib/powncer/link.rb', line 5

def initialize(options = {})
  options[:url] ||= ""
  raise RequirementMissing unless options[:url].is_valid_url?
  super
  @attributes["url"] = options[:url]
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



14
15
16
17
18
19
20
21
22
# File 'lib/powncer/link.rb', line 14

def create(attributes)
  attributes.symbolize_keys!
  link = self.new(attributes)
  unless link.to.is_a?(Symbol)
   target_key = self.superclass.ensure_send_to(:friend, link.to)
  end
  url = "/send/link.#{self.superclass::FORMAT}"
  Link.instantiate post(url, {:body => link.body, :to => target_key || link.to, :url => link.url})
end