Class: DropboxApi::Metadata::Tag

Inherits:
Base
  • Object
show all
Defined in:
lib/dropbox_api/metadata/tag.rb

Direct Known Subclasses

AccessLevel, MemberAction

Class Method Summary collapse

Methods inherited from Base

field, #initialize, #serialized_field, #to_hash

Constructor Details

This class inherits a constructor from DropboxApi::Metadata::Base

Class Method Details

.new(data) ⇒ Object


3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/dropbox_api/metadata/tag.rb', line 3

def self.new(data)
  case data
  when ::Symbol
    validate(data)
  when Hash
    new(data[".tag"].to_sym)
  when String
    new(data.to_sym)
  else
    raise ArgumentError, "Invalid object for #{name}: #{data.inspect}."
  end
end

.validate(value) ⇒ Object


16
17
18
19
20
21
22
# File 'lib/dropbox_api/metadata/tag.rb', line 16

def self.validate(value)
  if valid_values.include? value
    value
  else
    raise ArgumentError, "Invalid value for #{name}: #{value.inspect}"
  end
end