Blueprints 2.0: extensions

9 views
Skip to first unread message

Andrius Chamentauskas

unread,
Nov 7, 2011, 6:03:05 PM11/7/11
to blueprints
I'm removing Class.blueprint and instance.blueprint extensions.
Instead going for this syntax (I'm not sure if type and instance are
the best keywords here):
type(User).blueprint :admin...
type(Project) do
blueprint :project1
blueprint :project2 do
instance.find(12) # Project.find(12)
end
end

I'm also planning to change how extensions are defined by allowing
them to be defined in blueprints files. It will look something like
this:
extend ActiveRecord::Base do
# Build with default strategy
default do
instance.create!(attributes, :without_protection => true)
end

# Build with update strategy
update do
instance.update_attributes!(attributes, :without_protection =>
true)
end
end
require 'blueprints/extensions/mongoid' # or use extensions from
blueprints itself

Also this is very experimental, but I think I'll add some more
syntatic sugar with method missing to allow defining blueprints
without blueprint method:
type(User).admin :username => 'admin' # translates to
type(User).blueprint :admin...

Reply all
Reply to author
Forward
0 new messages