Sha256: 21194e17c5431a841decc37e79f5a771d3fec207f55fb69fe903f03435ca5f23

Contents?: true

Size: 742 Bytes

Versions: 2

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?
      %i[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

2 entries across 2 versions & 1 rubygems

Version Path
dry-web-roda-0.5.1 lib/dry/web/roda/skeletons/umbrella/lib/__underscored_app_name__/page.rb.tt
dry-web-roda-0.5.0 lib/dry/web/roda/skeletons/umbrella/lib/__underscored_app_name__/page.rb.tt