Class: Medie::Json::Links

Inherits:
Object
  • Object
show all
Defined in:
lib/medie/json/links.rb

Overview

represents a set of links using json

Instance Method Summary collapse

Constructor Details

#initialize(parent_node) ⇒ Links

Returns a new instance of Links.



6
7
8
# File 'lib/medie/json/links.rb', line 6

def initialize(parent_node)
  @node = parent_node
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/medie/json/links.rb', line 14

def method_missing(symbol, *args, &block)
  linkset = @node.select {|link| link.rel == symbol.to_s }
  linkset.map! { |link| Medie::Link.new(link) }
  unless linkset.empty?
    linkset.size == 1 ? linkset.first : linkset
  else
    nil
  end
end

Instance Method Details

#refreshObject



10
11
12
# File 'lib/medie/json/links.rb', line 10

def refresh
  links.self.follow.get
end