Skip to content

Commit

Permalink
refactored dsl
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermesilveira committed Oct 21, 2010
1 parent 07e68b0 commit 97828bf
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions lib/restfulie.rb
Expand Up @@ -5,21 +5,24 @@
require 'restfulie/client'
require 'restfulie/server'

class RestfulieDslBuilder
def initialize
@traits = [Restfulie::Client::Feature::Nil.new]
end
def method_missing(sym, *args)
trait = "Restfulie::Client::Feature::#{sym.to_s.classify}".constantize
@traits << trait
self.extend trait
self
end
end

# Shortcut to Restfulie::Client::EntryPoint
module Restfulie

class RestfulieDsl

def initialize
@traits = [Restfulie::Client::Feature::Nil.new]
end

def method_missing(sym, *args)
trait = "Restfulie::Client::Feature::#{sym.to_s.classify}".constantize
@traits << trait
self.extend trait
self
end

end

# creates a new entry point for executing requests
def self.at(uri)
Restfulie.using {
Expand All @@ -35,7 +38,7 @@ def self.using(&block)
end

def self.use(&block)
RestfulieDslBuilder.new.instance_eval(&block)
RestfulieDsl.new.instance_eval(&block)
end

end
Expand Down

0 comments on commit 97828bf

Please sign in to comment.