On Tuesday, March 22, 2016 at 7:00:21 AM UTC-7, Alexander Popov wrote:
>
> How I can fill mocked database for returning correct object or nil for
> queries? For example:
>
> @Album.dataset._fetch = {:id=>1,:name=>'Al'} # or another magic method,
> that's working like INSERT
> @Album.find(:name=>'Al') # => #<@values={:id=>1, :name=>"Al"}>
> @Album.find(:name=>'Al2') # => nil
>
>
Pass a proc to _fetch, it gets called with the SQL, and you can inspect the
SQL to choose what to return.
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.