Module: BraintreeTransparentRedirectSlice

Defined in:
lib/braintree_transparent_redirect_slice.rb,
lib/braintree_transparent_redirect_slice/version.rb

Overview

All Slice code is expected to be namespaced inside a module

Defined Under Namespace

Classes: Application, CreditCards, Main, Payments

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.activateObject

Activation hook - runs after AfterAppLoads BootLoader



57
58
# File 'lib/braintree_transparent_redirect_slice.rb', line 57

def self.activate
end

.configObject



42
43
44
# File 'lib/braintree_transparent_redirect_slice.rb', line 42

def self.config
  @config ||= { }
end

.deactivateObject

Deactivation hook - triggered by Merb::Slices.deactivate(BraintreeTransparentRedirectSlice)



61
62
# File 'lib/braintree_transparent_redirect_slice.rb', line 61

def self.deactivate
end

.initObject

Initialization hook - runs before AfterAppLoads BootLoader



47
48
49
50
51
52
53
54
# File 'lib/braintree_transparent_redirect_slice.rb', line 47

def self.init
  bt = YAML.load_file(Merb.root / 'config' / 'braintree.yml')
  if bt[Merb.env]
    bt[Merb.env].each do |k,v|
      config[k.to_sym] = v
    end
  end
end

.loadedObject

Stub classes loaded hook - runs before LoadClasses BootLoader right after a slice’s classes have been loaded internally.



39
40
# File 'lib/braintree_transparent_redirect_slice.rb', line 39

def self.loaded
end

.setup_router(scope) ⇒ Object

Note:

prefix your named routes with :braintree_transparent_redirect_slice_ to avoid potential conflicts with global named routes.

Setup routes inside the host application

Parameters:

  • scope (Merb::Router::Behaviour)

    Routes will be added within this scope (namespace). In fact, any router behaviour is a valid namespace, so you can attach routes at any level of your router setup.



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/braintree_transparent_redirect_slice.rb', line 73

def self.setup_router(scope)
  scope.resources :credit_cards, :member     => {:edit_response => :get},
                                 :collection => {:new_response  => :get}  do |cards|
    cards.resources :payments,   :collection => {:new_response => :get}
  end
  # example of a named route
  #scope.match('/index(.:format)').to(:controller => 'main', :action => 'index').name(:index)
  # the slice is mounted at /braintree_transparent_redirect_slice - note that it comes before default_routes
  scope.match('/').to(:controller => :credit_cards).name(:braintree_home)
  # enable slice-level default routes by default
#      scope.default_routes
end