Sha256: 16ec07519f2d355ed58f6d48809fe550ea4d61e0a08364c44bdcf0e33571df48

Contents?: true

Size: 515 Bytes

Versions: 2

Compression:

Stored size: 515 Bytes

Contents

# frozen_string_literal: true

module Consent
  class Action # :nodoc:
    attr_reader :subject, :key, :label, :options

    def initialize(subject, key, label, options = {})
      @subject = subject
      @key = key
      @label = label
      @options = options
    end

    def views
      @views ||= @subject.views.slice(*@options.fetch(:views, []))
    end

    def default_view
      return unless @options.key?(:default_view)

      @default_view ||= @subject.views[@options[:default_view]]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
consent-2.0.0 lib/consent/action.rb
consent-1.0.1 lib/consent/action.rb