Sha256: 2b9dd1a43e7cbf9963f139e325f9ae84a50ed65ba56976805b7811b9d5a4ac7c

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'voom/presenters/dsl/components/base'

module Voom
  module Presenters
    module DSL
      module Components
        module Actions
          class Base < Components::Base
            # Options are used by the actions
            # Params are passed by the user
            attr_reader :params, :options

            def initialize(type:, **attribs_, &block)
              super(type: type, **attribs_, &block)
              @options = {}
              extract_options!
              @params = attribs.delete(:params) {{}}
              @url = nil
            end

            def url
              @parent.router.url(render: options[:presenter], command: options[:path], context: params)
            end

            private
            def extract_options!
              %i(path presenter target input_tag).each do |option|
                optionValue = attribs.delete(option)
                @options.merge!({option => optionValue}) if optionValue
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
voom-presenters-0.2.0 lib/voom/presenters/dsl/components/actions/base.rb