Comments (4)
Hmmm, not sure. It'd be a mess to implement on top of the current named blueprints and caching mechanism.
I'd rather find some way to pass stuff like this in as extra arguments, but I'm not sure how to fit that in with the existing arguments to make.
from machinist.
Are you thinking something like:
Post.blueprint(:with_comments, :blueprint_params => [:num_comments]) do |params|
# ...
comments(params[:num_comments].to_i)
end
Post.make(:with_comments, :num_comments => 3)
That syntax for making the objects feels less clear to me. Keeping pecs/tests as clear and concise as possible is paramount for me. However, having this functionality is more important than the syntax. If you have a strong preference i am open to implementing that.
I haven't looked at the internals of the caching mechanism yet. I'll take a look soon an see if i can see an approach to caching the results of parameterized blueprints.
from machinist.
the randexp gem would work great for this, check it out
from machinist.
The caching mechanism is now gone, but this still all feels a bit too magic to me. I'd just make some nice helper methods that wrap calls to Machinist if I was doing the same thing.
That said, feel free to fork and give it a go. You may come up with something that surprises me, and even if you don't, there's no harm in having a fork that meets your needs.
Or you can always make another gem that extends Machinist. (I'm encouraging the guys working on DataMapper support to make a machinist-dm gem, for example.)
from machinist.
Related Issues (20)
- More of a feature request: switchable associations HOT 3
- Incompatible with presence validation on associated record HOT 3
- Machinist2 and dirty tracking HOT 1
- Allow "make" to take a block
- rspec issue: no master blueprint defined HOT 3
- Update Machinist Wiki
- 1.0 Maintenance: Object#type Deprecation warning
- Blueprint file not found when using Capybara and spec HOT 3
- calling `make` or `make!` on an association does not set the new object's association to the calling object HOT 4
- Role Model printing: #<Machinist::ActiveRecord::Lathe: HOT 2
- sn method does not work
- When the association being passed to make!, machinist should not instantiate it HOT 1
- Problem with models that use FriendlyID HOT 1
- Association named 'test' raise the error "wrong number of arguments (given 0, expected 2..3)"
- Allow me to push to Machinist on Rubygems
- Feature request: post processing after object is initialized HOT 1
- Installation problem HOT 1
- Blueprint for has_one associations HOT 7
- Admin::User.blueprint doesn't work HOT 3
- Machinist make! generate a model that raise ActiveRecord::RecordNotFound on reload HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from machinist.