Can I conditionaly initializer?

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
I initializer “spree.gateway.payment_methods_china”, :after => "
spree.gateway.payment_methods"
when spree_gateway doesn’t exist,
I 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
http://www.aisiming.com/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs