Ruby libs shot
Friday, May 4, 2012 Posted by Unknown at 09:37 0 commentsmethod_decorators
Jealous of Java, C#, etc method annotations? Here's a mini gem that gives you the opportunity to do this in Ruby! Watch out :
class ExternalService extend MethodDecorators +Retry.new(3) def request ... end end
Spotted through Extending Ruby with Ruby (with explanation and other cool ideas)
anise
Dynamic code annotations
class X
extend Anise::Annotative::Attributes
attr :baz, Integer, :max => 10
end
X.ann(:baz) #=> {:class=>Integer, :max=>10}
Source and info : https://github.com/rubyworks/anise
Her
An "ORM" for REST apis instead of database models
Her::API.setup :base_uri => "https://api.example.com" do |builder| builder.use Faraday::Request::UrlEncoded builder.use Her::Middleware::DefaultParseJSON builder.use Faraday::Adapter::NetHttp end
class User include Her::Model end
User.all # GET https://api.example.com/users and return an array of User objects User.find(1) # GET https://api.example.com/users/1 and return a User object @user = User.create(:fullname => "Tobias Fünke") # POST "https://api.example.com/users" with the data and return a User object @user = User.new(:fullname => "Tobias Fünke") @user.occupation = "actor" @user.save # POST https://api.example.com/users with the data and return a User object @user = User.find(1) @user.fullname = "Lindsay Fünke" @user.save # PUT https://api.example.com/users/1 with the data and return+update the User object
Info and source : http://remiprev.github.com/her/
Spotted through http://notes.exomel.com/2012/04/her-an-orm-for-rest-apis.html
Subscribe to:
Posts (Atom)