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.8.10.2 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.8.10.1 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.8.9.11 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.8.10 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.8.9 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.8.8 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.8.7 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.8.6 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.8.5 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.8.4 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.8.3 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.8.2 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.8.1 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.8.0 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.19 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.18 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.17 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.16 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.15 flydata-core/lib/flydata-core/option_validator.rb
flydata-0.7.14 flydata-core/lib/flydata-core/option_validator.rb