Sha256: ef50109c61e611cc504ff2d3c050cf5d7c93b362f66cd49103b390c641cc898c

Contents?: true

Size: 558 Bytes

Versions: 1

Compression:

Stored size: 558 Bytes

Contents

module Tumblr
  module Helper

    def validate_options(valid_opts, opts)
      bad_opts = opts.select { |val| !valid_opts.include?(val) }
      if bad_opts.any?
        raise ArgumentError.new "Invalid options (#{bad_opts.keys.join(', ')}) passed, only #{valid_opts} allowed."
      end
    end

    def validate_no_collision(options, attributes)
      count = attributes.count { |attr| options.has_key?(attr) }
      if count > 1
        raise ArgumentError.new "Can only use one of: #{attributes.join(', ')} (Found #{count})"
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tumblr_client-0.7.0 lib/tumblr/helpers.rb