Sha256: 42e45f839b196c6717e10f1e0ded29f4066bc30d6973f80effb0a73472d1bb37

Contents?: true

Size: 1.14 KB

Versions: 31

Compression:

Stored size: 1.14 KB

Contents

# Provide helper method for common processing of configurations.
module Qa
  module LinkedData
    module Config
      class Helper
        # Fetch a value from a hash map
        def self.fetch(map, key, default)
          map.fetch(key, default)
        end

        # Fetch a boolean value from a hash map throwing an exception if the value is not boolean
        def self.fetch_boolean(map, key, default)
          value = map.fetch(key, default)
          raise Qa::InvalidConfiguration, "#{key} must be true or false" unless value == true || value == false
          value
        end

        # Fetch a value from a hash map throwing an exception if the value is blank
        def self.fetch_required(map, key, default)
          value = map.fetch(key, default)
          raise Qa::InvalidConfiguration, "#{key} is required" unless value
          value
        end

        # Fetch a value from a hash map throwing an exception if the value is blank
        def self.fetch_symbol(map, key, default)
          value = map.fetch(key, default)
          return value unless value.respond_to? :to_sym
          value.to_sym
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
qa-5.14.0 app/models/qa/linked_data/config/helper.rb
qa-5.13.0 app/models/qa/linked_data/config/helper.rb
qa-5.12.0 app/models/qa/linked_data/config/helper.rb
qa-5.11.0 app/models/qa/linked_data/config/helper.rb
qa-5.10.0 app/models/qa/linked_data/config/helper.rb
qa-5.9.0 app/models/qa/linked_data/config/helper.rb
qa-5.8.1 app/models/qa/linked_data/config/helper.rb
qa-5.8.0 app/models/qa/linked_data/config/helper.rb
qa-5.7.0 app/models/qa/linked_data/config/helper.rb
qa-5.6.0 app/models/qa/linked_data/config/helper.rb
qa-5.5.2 app/models/qa/linked_data/config/helper.rb
qa-4.3.0 app/models/qa/linked_data/config/helper.rb
qa-5.5.1 app/models/qa/linked_data/config/helper.rb
qa-5.5.0 app/models/qa/linked_data/config/helper.rb
qa-5.4.0 app/models/qa/linked_data/config/helper.rb
qa-5.3.1 app/models/qa/linked_data/config/helper.rb
qa-5.3.0 app/models/qa/linked_data/config/helper.rb
qa-5.2.0 app/models/qa/linked_data/config/helper.rb
qa-5.1.0 app/models/qa/linked_data/config/helper.rb
qa-5.0.0 app/models/qa/linked_data/config/helper.rb