Sha256: 6a06c3c89b53f7e4b448d9d0b11c783519894ad13604a38fbe2e5d2b7ba8942d

Contents?: true

Size: 927 Bytes

Versions: 14

Compression:

Stored size: 927 Bytes

Contents

require_relative 'base'

module Voom
  module Presenters
    module DSL
      module Components
        class Action < 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).each do |option|
              optionValue = attribs.delete(option)
              @options.merge!({option => optionValue}) if optionValue
            end
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
voom-presenters-0.1.13 lib/voom/presenters/dsl/components/action.rb
voom-presenters-0.1.12 lib/voom/presenters/dsl/components/action.rb
voom-presenters-0.1.11 lib/voom/presenters/dsl/components/action.rb
voom-presenters-0.1.10 lib/voom/presenters/dsl/components/action.rb
voom-presenters-0.1.9 lib/voom/presenters/dsl/components/action.rb
voom-presenters-0.1.8 lib/voom/presenters/dsl/components/action.rb
voom-presenters-0.1.7 lib/voom/presenters/dsl/components/action.rb
voom-presenters-0.1.6 lib/voom/presenters/dsl/components/action.rb
voom-presenters-0.1.5 lib/voom/presenters/dsl/components/action.rb
voom-presenters-0.1.4 lib/voom/presenters/dsl/components/action.rb
voom-presenters-0.1.3 lib/voom/presenters/dsl/components/action.rb
voom-presenters-0.1.2 lib/voom/presenters/dsl/components/action.rb
voom-presenters-0.1.1 lib/voom/presenters/dsl/components/action.rb
voom-presenters-0.1.0 lib/voom/presenters/dsl/components/action.rb