Sha256: bd6893c24cc778f4cb972c7b99a8c3202613d0e8d49225b4a5b267e8093834ef

Contents?: true

Size: 940 Bytes

Versions: 112

Compression:

Stored size: 940 Bytes

Contents

module Lalala::Pages::RouteMapper

  # pages(:about, to: 'about#show')
  # pages(:about, to: 'about#show') do
  #   get '/team/:member', to: 'about#team_member'
  # end
  # pages(:about) do
  #   get '/team/:member', to: 'about#team_member'
  # end
  def pages(*args)
    options = args.extract_options!
    options = options.dup

    unless args.size == 1 and Symbol === args[0]
      raise ArgumentError, "expected a page type"
    end

    type    = Lalala::Pages::RouteMapper.page_class_name(args[0])
    options = { as: type.underscore }.merge(options)
    options[:constraints] = Lalala::Pages::PageTypeConstraint.new(type)

    match '/', options

    if block_given?
      scope(options.except(:to,:action,:controller)) { yield }
    end

    self
  end

  def self.page_class_name(type)
    type = "#{type}_page"
    type = type.classify

    while type.ends_with?("PagePage")
      type = type[0..-5]
    end

    type
  end

end

Version data entries

112 entries across 112 versions & 1 rubygems

Version Path
lalala-4.1.0.dev.392 lib/lalala/pages/route_mapper.rb
lalala-4.0.0.dev.393 lib/lalala/pages/route_mapper.rb
lalala-4.1.0.dev.391 lib/lalala/pages/route_mapper.rb
lalala-4.1.0.dev.390 lib/lalala/pages/route_mapper.rb
lalala-4.1.0.dev.389 lib/lalala/pages/route_mapper.rb
lalala-4.0.0.dev.388 lib/lalala/pages/route_mapper.rb
lalala-4.1.0.dev.387 lib/lalala/pages/route_mapper.rb
lalala-4.1.0.dev.386 lib/lalala/pages/route_mapper.rb
lalala-4.0.0.dev.385 lib/lalala/pages/route_mapper.rb
lalala-4.1.0.dev.384 lib/lalala/pages/route_mapper.rb
lalala-4.0.0.dev.382 lib/lalala/pages/route_mapper.rb
lalala-4.1.0.dev.381 lib/lalala/pages/route_mapper.rb
lalala-4.1.0.dev.376 lib/lalala/pages/route_mapper.rb
lalala-4.1.0.dev.375 lib/lalala/pages/route_mapper.rb
lalala-4.0.0.dev.374 lib/lalala/pages/route_mapper.rb
lalala-4.0.0.dev.372 lib/lalala/pages/route_mapper.rb
lalala-4.0.0.dev.368 lib/lalala/pages/route_mapper.rb
lalala-4.1.0.dev.367 lib/lalala/pages/route_mapper.rb
lalala-4.0.0.dev.366 lib/lalala/pages/route_mapper.rb
lalala-4.1.0.dev.360 lib/lalala/pages/route_mapper.rb