Skip to content

Instantly share code, notes, and snippets.

@rainerborene
Created January 17, 2012 13:42
Show Gist options
  • Save rainerborene/1626666 to your computer and use it in GitHub Desktop.
Save rainerborene/1626666 to your computer and use it in GitHub Desktop.
# encoding: utf-8
class Depot
attr_accessor :entries
def self.construct(&block)
new.tap do |depot|
depot.entries = {}
depot.instance_eval(&block)
end
end
def create(attributes = {})
puts "quem é o model do method_missing? :("
puts attributes.inspect
end
def models
@models ||= [:groups]
end
def method_missing(name, &block)
if models.include? name
instance_eval(&block)
else
super
end
end
end
Depot.construct do
groups do
create :teste => "hello world", :as => :hello
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment