class Magnetik::Rails::Routes

Attributes

routes[RW]

Public Class Methods

install!() click to toggle source
# File lib/magnetik/rails/routes.rb, line 13
def self.install!
  ActionDispatch::Routing::Mapper.send :include, Magnetik::Rails::Routes::Helper
end
new(routes, &block) click to toggle source
# File lib/magnetik/rails/routes.rb, line 19
def initialize(routes, &block)
  @routes, @block = routes, block
end

Public Instance Methods

generate_routes!(options) click to toggle source
# File lib/magnetik/rails/routes.rb, line 23
def generate_routes!(options)
  @mapping = Mapper.new.map(&@block)
  routes.scope options[:scope] || '', as: 'magnetik' do
    map_route(:credit_cards, :credit_card_routes)
  end
end

Private Instance Methods

credit_card_routes(mapping) click to toggle source
# File lib/magnetik/rails/routes.rb, line 38
def credit_card_routes(mapping)
  routes.resources(
    :credit_cards,
    controller: mapping[:controllers],
    as: :credit_cards,
    path: 'credit_cards',
    only: [:index, :create, :update, :destroy],
  )
end
map_route(name, method) click to toggle source
# File lib/magnetik/rails/routes.rb, line 32
def map_route(name, method)
  unless @mapping.skipped?(name)
    send method, @mapping[name]
  end
end