Sha256: 29232892bf7c0a7b1890aee209a6f147adff0867051d67ae12e50a9d8e4e0620

Contents?: true

Size: 750 Bytes

Versions: 69

Compression:

Stored size: 750 Bytes

Contents

module FlydataCore

module OptionValidator
  def self.included(base)
    base.extend(ClassMethods)
  end

  def validate_options(o, options = nil)
    self.class.validate_options(o, options)
  end

  module ClassMethods
    def validate_options(o, options = nil)
      if (options.nil?)
        unless defined?(self::OPTIONS)
          raise "validate_options needs OPTIONS hash defined"
        end
        options = self::OPTIONS
      end

      result = o.clone

      options.keys.each do |k|
        unless (result.has_key?(k))
          if (options[k] != :mandatory)
            result[k] = options[k]
          else
            raise "Mandatory option #{k} is missing"
          end
        end
      end

      result
    end
  end
end

end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
flydata-0.7.13 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.12 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.11 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.10 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.9 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.8 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.7 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.6 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.5 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.4 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.2.1 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.2 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.1 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.0 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.6.14 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.6.13 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.6.12 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.6.11 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.6.10 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.6.9 flydata-core/lib/flydata-core/option_validator.rb