Sha256: 1beb090833e4b3d2729682a043084c6d88ec0134fc1fbf4ea42a5fce8ef35ff2

Contents?: true

Size: 572 Bytes

Versions: 7

Compression:

Stored size: 572 Bytes

Contents

module <%= config[:camel_cased_app_name] %>
  class ViewContext
    attr_reader :attrs

    def initialize(attrs = {})
      @attrs = attrs
    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(new_attrs)
      self.class.new(attrs.merge(new_attrs))
    end

    private

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

Version data entries

7 entries across 4 versions & 1 rubygems

Version Path
dry-web-roda-0.6.3 lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/view_context.rb.tt
dry-web-roda-0.6.3 lib/dry/web/roda/skeletons/umbrella_project/lib/__underscored_app_name__/view_context.rb.tt
dry-web-roda-0.6.2 lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/view_context.rb.tt
dry-web-roda-0.6.2 lib/dry/web/roda/skeletons/umbrella_project/lib/__underscored_app_name__/view_context.rb.tt
dry-web-roda-0.6.1 lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/view_context.rb.tt
dry-web-roda-0.6.1 lib/dry/web/roda/skeletons/umbrella_project/lib/__underscored_app_name__/view_context.rb.tt
dry-web-roda-0.6.0 lib/dry/web/roda/skeletons/umbrella/lib/__underscored_app_name__/view_context.rb.tt