Ruby on Rails Tuesday, March 27, 2012

Hello, I'm trying to add to spree functionlity

gateway of china, I check out the documentation and
follow the spree_gateway, in engine.rb

initializer "spree.gateway.payment_methods", :after => "spree.register.payment_methods" do |app|
        app.config.spree.payment_methods << Spree::Gateway::AuthorizeNetCim
        app.config.spree.payment_methods << Spree::Gateway::AuthorizeNet
        app.config.spree.payment_methods << Spree::Gateway::Eway
        app.config.spree.payment_methods << Spree::Gateway::Linkpoint
        app.config.spree.payment_methods << Spree::Gateway::PayPal
        app.config.spree.payment_methods << Spree::Gateway::SagePay
        app.config.spree.payment_methods << Spree::Gateway::Beanstream
        app.config.spree.payment_methods << Spree::Gateway::Braintree
        app.config.spree.payment_methods << Spree::Gateway::Stripe
        app.config.spree.payment_methods << Spree::Gateway::Samurai
end

so my,

initializer "spree.gateway.payment_methods_china", :after => "spree.gateway.payment_methods" do |app|
        app.config.spree.payment_methods << Spree::Gateway::Alipay
end

I hope to write my gem more general,
so when spree_gateway exists
initializer "spree.gateway.payment_methods_china", :after => "spree.gateway.payment_methods"
when spree_gateway doesn't exist,
initializer "spree.gateway.payment_methods_china", :after => "spree.register.payment_methods"

is it possible for rails engine to some kind conditionally say whether a initializer block exists?
(of course it doesn't matter in my case, my payment gateway registers before spree_gateway is also ok,
but is it possible to have this flexibility?
Thanks.

--
http://hi.baidu.com/femto

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment