Sha256: e4cb6339c7a75183275cdd9ce14e520a939db93dea8545f83679decdce3495e7

Contents?: true

Size: 827 Bytes

Versions: 7

Compression:

Stored size: 827 Bytes

Contents

# frozen_string_literal: true

require_relative 'validation'
require_relative '../../model'

module Lino
  module Builders
    module Mixins
      module Arguments
        include Validation

        def initialize(state)
          @arguments = Hamster::Vector.new(state[:arguments] || [])
          super
        end

        def with_argument(argument)
          return self if argument.nil?
          return self if empty?(argument.to_s)

          with(arguments: @arguments.add(Model::Argument.new(argument)))
        end

        def with_arguments(arguments)
          return self if nil_or_empty?(arguments)

          arguments.inject(self) { |s, argument| s.with_argument(argument) }
        end

        private

        def state
          super.merge(arguments: @arguments)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lino-4.2.0.pre.2 lib/lino/builders/mixins/arguments.rb
lino-4.2.0.pre.1 lib/lino/builders/mixins/arguments.rb
lino-4.1.0 lib/lino/builders/mixins/arguments.rb
lino-4.1.0.pre.2 lib/lino/builders/mixins/arguments.rb
lino-4.1.0.pre.1 lib/lino/builders/mixins/arguments.rb
lino-4.0.0 lib/lino/builders/mixins/arguments.rb
lino-4.0.0.pre.2 lib/lino/builders/mixins/arguments.rb