Module: Rooftop::ResourceLinks

Defined in:
lib/rooftop/resource_links/link.rb,
lib/rooftop/resource_links/collection.rb,
lib/rooftop/resource_links/resource_links.rb,
lib/rooftop/errors/unresolveable_link_error.rb

Defined Under Namespace

Modules: ClassMethods Classes: Collection, Link, UnresolvableLinkError

Constant Summary collapse

"http://docs.rooftopcms.com/link_relations"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/rooftop/resource_links/resource_links.rb', line 5

def self.included(base)
  # set up an attribute called resource_links, which is a collection of links
  # to other resources in the API.
  base.send(:after_find, :generate_resource_links)
  base.send(:after_save, :generate_resource_links)
  base.extend ClassMethods
  base.configure_resource_link_mapping
end

Instance Method Details



14
15
16
17
18
# File 'lib/rooftop/resource_links/resource_links.rb', line 14

def generate_resource_links
  if self.respond_to?(:"_links")
    self.resource_links = Rooftop::ResourceLinks::Collection.new(self._links, self.class)
  end
end