Sha256: db6617e4b9fdac26996da494aa2ec6eb52ed27e50dbb3cc45f2cc96db9789ac7

Contents?: true

Size: 742 Bytes

Versions: 6

Compression:

Stored size: 742 Bytes

Contents

module <%= config[:camel_cased_app_name] %>
  class Page
    attr_reader :options

    def initialize(options = {})
      @options = options
    end

    def view_locals
      {
        csrf_token: csrf_token,
        csrf_tag: csrf_tag,
      }
    end

    def csrf_token
      self[:csrf_token].()
    end

    def csrf_metatag
      self[:csrf_metatag].()
    end

    def csrf_tag
      self[:csrf_tag].()
    end

    def flash
      self[:flash]
    end

    def flash?
      %w(notice alert).any? { |type| flash[type] }
    end

    def with_flash(flash)
      with(flash: flash)
    end

    def with(new_options)
      self.class.new(options.merge(new_options))
    end

    def [](name)
      options.fetch(name)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dry-web-roda-0.4.0 lib/dry/web/roda/skeletons/umbrella/lib/__underscored_app_name__/page.rb.tt
dry-web-roda-0.3.0 lib/dry/web/roda/skeletons/umbrella/lib/__underscored_app_name__/page.rb.tt
dry-web-roda-0.2.3 lib/dry/web/roda/skeletons/umbrella/lib/__underscored_app_name__/page.rb.tt
dry-web-roda-0.2.2 lib/dry/web/roda/skeletons/umbrella/lib/__underscored_app_name__/page.rb.tt
dry-web-roda-0.2.1 lib/dry/web/roda/skeletons/umbrella/lib/__underscored_app_name__/page.rb.tt
dry-web-roda-0.2.0 lib/dry/web/roda/skeletons/umbrella/lib/__underscored_app_name__/page.rb.tt