Class: Medie::Json::Links
- Inherits:
-
Object
- Object
- Medie::Json::Links
- Defined in:
- lib/medie/json/links.rb
Overview
represents a set of links using json
Instance Method Summary collapse
-
#initialize(parent_node) ⇒ Links
constructor
A new instance of Links.
- #method_missing(symbol, *args, &block) ⇒ Object
- #refresh ⇒ Object
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
#refresh ⇒ Object
10 11 12 |
# File 'lib/medie/json/links.rb', line 10 def refresh links.self.follow.get end |