Sha256: e0d2d3dd20a0d2c601a2d5b1ea8453324f49a295b50a412050d476a9db12a812

Contents?: true

Size: 765 Bytes

Versions: 10

Compression:

Stored size: 765 Bytes

Contents

# frozen_string_literal: true

# Collection to store, merge and validate arguments
module Light
  module Services
    module Collection
      class Arguments < Base
        def extend_with_context(args)
          settings_collection.each do |name, settings|
            next if !settings.context || args.key?(name) || !key?(name)

            args[settings.name] = get(name)
          end

          args
        end

        def validate!
          settings_collection.each do |name, settings|
            next if settings.optional && (!key?(name) || get(name).nil?)

            settings.valid_type?(get(name))
          end
        end

        private

        def settings_collection
          @instance.class.arguments
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
light-services-2.0 lib/light/services/collection/arguments.rb
light-services-2.0.0.rc9 lib/light/services/collection/arguments.rb
light-services-2.0.0.rc8 lib/light/services/collection/arguments.rb
light-services-2.0.0.rc7 lib/light/services/collection/arguments.rb
light-services-2.0.0.rc6 lib/light/services/collection/arguments.rb
light-services-2.0.0.rc4 lib/light/services/collection/arguments.rb
light-services-2.0.0.rc3 lib/light/services/collection/arguments.rb
light-services-2.0.0.rc2 lib/light/services/collection/arguments.rb
light-services-2.0.0.rc1 lib/light/services/collection/arguments.rb
light-services-2.0.0.beta1 lib/light/services/collection/arguments.rb