Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
class Hash | ||
|
||
def links(*args) | ||
links = fetch("link", []) | ||
Restfulie::Common::Converter::Xml::Links.new(links) | ||
end | ||
|
||
include Restfulie::Common::Links | ||
|
||
def method_missing(sym, *args) | ||
self[sym.to_s].nil? ? super(sym, args) : self[sym.to_s] | ||
end | ||
|
||
def respond_to?(sym) | ||
include?(sym.to_s) || super(sym) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Restfulie | ||
module Common | ||
module Links | ||
def refresh | ||
links.self.follow.get | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
module Restfulie::Common::Representation | ||
autoload :Atom, 'restfulie/common/representation/atom' | ||
autoload :Generic, 'restfulie/common/representation/generic' | ||
autoload :Json, 'restfulie/common/representation/json' | ||
autoload :Links, 'restfulie/common/representation/links' | ||
Dir["#{File.dirname(__FILE__)}/representation/*.rb"].each {|f| autoload File.basename(f)[0..-4].camelize.to_sym, f } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') | ||
|
||
describe Restfulie::Common::Links do | ||
|
||
class RefreshieLinks | ||
include Restfulie::Common::Links | ||
def initialize(what) | ||
@what = what | ||
end | ||
def links | ||
RefreshieSelf.new(@what) | ||
end | ||
end | ||
|
||
class RefreshieSelf | ||
def initialize(what) | ||
@what = what | ||
end | ||
def self | ||
RefreshieFollow.new(@what) | ||
end | ||
end | ||
|
||
class RefreshieGet | ||
def initialize(what) | ||
@what = what | ||
end | ||
def get | ||
@what | ||
end | ||
end | ||
|
||
class RefreshieFollow | ||
def initialize(what) | ||
@what = what | ||
end | ||
def follow | ||
RefreshieGet.new(@what) | ||
end | ||
end | ||
|
||
it "should get self when refreshing itself" do | ||
RefreshieLinks.new("myself").refresh.should == "myself" | ||
end | ||
|
||
end |