Not overly relevant but I like how OmniAuth allows you to put it into test mode
so it will return fake data rather than hitting providers. Very useful in
development mode!
Also I tend to configure my APIs on a per environment basis, and have those
settings in the relevant environment/#{env}.rb file. I find this to be a lot
more flexible/cleaner than littering code with Rails.env.environment? calls.
Jon Rowe
-----------------------------
[email protected]
jonrowe.co.uk
On Wednesday, 14 November 2012 at 00:37, Sebastian Porto wrote:
> I think DI is a nice way to go. Combined with some constants in an
> initializer.
>
> class PurchaseProduct
> def buy_it_now
> acme = acme_provider.new(subscriber)
> result = acme.pay_money
> end
>
> def acme_provider
> @acme_provider ||= ACME_PROVIDER
> end
>
> def acme_provider=(obj)
> @acme_provider = obj
> end
> end
>
>
> if Rails.env.development?
> ACME_PROVIDER = FakeAcme
> else
> ACME_PROVIDER = Acme
> end
>
>
> It is also very easy to swap the dependency in the test:
>
> pp = PurchaseProduct.new
> pp.acme_provider = FakeAcme
>
>
> Sebastian
>
>
>
>
> Steve Hoeksema wrote:
> > class PurchaseProduct(acme_provider)
> > def buy_it_now
> > acme = acme_provider.new(subscriber)
> > result = acme.pay_money
> > end
> > end
> >
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby or Rails Oceania" group.
> To post to this group, send email to [email protected]
> (mailto:[email protected]).
> To unsubscribe from this group, send email to
> [email protected]
> (mailto:[email protected]).
> For more options, visit this group at
> http://groups.google.com/group/rails-oceania?hl=en.
--
You received this message because you are subscribed to the Google Groups "Ruby
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rails-oceania?hl=en.