module Acoustid::API::Request::ParamValidations

Constants

VALID_META_VALUES

Public Instance Methods

serialize_integer(value) click to toggle source
# File lib/acoustid/api/request/param_validations.rb, line 13
def serialize_integer(value)
  value.nil? ? nil : value.to_i
end
serialize_meta(value) click to toggle source
# File lib/acoustid/api/request/param_validations.rb, line 17
def serialize_meta(value)
  value.nil? ? nil : value.to_a.collect { |value| value.to_s.strip }
end
serialize_string(value) click to toggle source
# File lib/acoustid/api/request/param_validations.rb, line 9
def serialize_string(value)
  value.nil? ? nil : value.to_s.strip
end
validate_duration(value) click to toggle source
# File lib/acoustid/api/request/param_validations.rb, line 25
def validate_duration(value)
  raise TypeError, 'duration must respond to :to_i' unless value.respond_to?(:to_i)
end
validate_format(value) click to toggle source
# File lib/acoustid/api/request/param_validations.rb, line 21
def validate_format(value)
  raise ArgumentError, '' unless %W[json jsonp xml].include?(value.to_s.strip)
end
validate_meta(value) click to toggle source
# File lib/acoustid/api/request/param_validations.rb, line 29
def validate_meta(value)
  raise TypeError, 'meta must respond to :to_a or be nil' unless value.nil? || value.respond_to?(:to_a)
  raise TypeError, "meta must only include #{ VALID_META_VALUES.join(', ') }" unless value.nil? || serialize_meta(value).all? { |meta| VALID_META_VALUES.include?(meta) }
  
  # TODO
end