Module: Rooftop::ResourceLinks::ClassMethods

Defined in:
lib/rooftop/resource_links/resource_links.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

This class-level attribute allows us to set a mapping between a resource link name (which is probably an href, but might be “up” or something) and a class. It means that when we try to resolve a link of a given name, we know what type of class to instantiate



24
25
26
# File 'lib/rooftop/resource_links/resource_links.rb', line 24

def resource_link_mapping
  @resource_link_mapping
end

Instance Method Details



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rooftop/resource_links/resource_links.rb', line 26

def configure_resource_link_mapping
  @resource_link_mapping ||= {}
  @resource_link_mapping.merge!({
                                "author" => Rooftop::Author,
                                "https://api.w.org/attachment" => Rooftop::MediaItem,
                                "self" => self,
                                "up" => self,
                                "http://docs.rooftopcms.com/link_relations/ancestors" => self,
                                "http://docs.rooftopcms.com/link_relations/children" => self
                              })
end