Sha256: 472ad9f70e6ede9bf4068e7da8c2609878dc2cb3bd58059abdde85b1bc40fab2

Contents?: true

Size: 763 Bytes

Versions: 2

Compression:

Stored size: 763 Bytes

Contents

# frozen_string_literal: true

module Sunrise
  module Config
    # A simple object that gets used to present different aspects of views
    #
    # Initialize with a set of options and a block. The options become
    # available using hash style syntax.
    #
    # Usage:
    #
    #     presenter = PagePresenter.new as: :table do
    #       # some awesome stuff
    #     end
    #
    #     presenter[:as]    #=> :table
    #     presenter.block   #=> The block passed in to new
    #
    class PagePresenter
      attr_reader :block, :options

      delegate :has_key?, to: :options

      def initialize(options = {}, &block)
        @options = options
        @block = block
      end

      def [](key)
        @options[key]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sunrise-cms-1.1.1 lib/sunrise/config/page_presenter.rb
sunrise-cms-1.1.0 lib/sunrise/config/page_presenter.rb