Class: Sidemash::Sdk::HttpMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/sidemash/sdk/http_method.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ HttpMethod

Returns a new instance of HttpMethod.



24
25
26
# File 'lib/sidemash/sdk/http_method.rb', line 24

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



22
23
24
# File 'lib/sidemash/sdk/http_method.rb', line 22

def value
  @value
end

Class Method Details

.all_possibles_valuesObject



48
49
50
51
52
53
54
# File 'lib/sidemash/sdk/http_method.rb', line 48

def self.all_possibles_values
  Set['GET',
      'POST',
      'PUT',
      'DELETE',
      'PATCH']
end

.deleteObject



40
41
42
# File 'lib/sidemash/sdk/http_method.rb', line 40

def self.delete
  HttpMethod.new('DELETE')
end

.from_s(value) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'lib/sidemash/sdk/http_method.rb', line 56

def self.from_s(value)
  case value
    when 'GET' then HttpMethod.get
    when 'POST' then HttpMethod.post
    when 'PUT' then HttpMethod.put
    when 'DELETE' then HttpMethod.delete
    when 'PATCH' then HttpMethod.patch
    else nil
  end
end

.getObject



28
29
30
# File 'lib/sidemash/sdk/http_method.rb', line 28

def self.get
  HttpMethod.new('GET')
end

.patchObject



44
45
46
# File 'lib/sidemash/sdk/http_method.rb', line 44

def self.patch
  HttpMethod.new('PATCH')
end

.postObject



32
33
34
# File 'lib/sidemash/sdk/http_method.rb', line 32

def self.post
  HttpMethod.new('POST')
end

.putObject



36
37
38
# File 'lib/sidemash/sdk/http_method.rb', line 36

def self.put
  HttpMethod.new('PUT')
end

.valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/sidemash/sdk/http_method.rb', line 67

def self.valid?(value)
  HttpMethod.all_possibles_values.include? value
end

Instance Method Details

#delete?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/sidemash/sdk/http_method.rb', line 103

def delete?
  @value == 'DELETE'
end

#get?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/sidemash/sdk/http_method.rb', line 91

def get?
  @value == 'GET'
end

#not_delete?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/sidemash/sdk/http_method.rb', line 83

def not_delete?
  @value != 'DELETE'
end

#not_get?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/sidemash/sdk/http_method.rb', line 71

def not_get?
  @value != 'GET'
end

#not_patch?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/sidemash/sdk/http_method.rb', line 87

def not_patch?
  @value != 'PATCH'
end

#not_post?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/sidemash/sdk/http_method.rb', line 75

def not_post?
  @value != 'POST'
end

#not_put?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/sidemash/sdk/http_method.rb', line 79

def not_put?
  @value != 'PUT'
end

#patch?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/sidemash/sdk/http_method.rb', line 107

def patch?
  @value == 'PATCH'
end

#post?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/sidemash/sdk/http_method.rb', line 95

def post?
  @value == 'POST'
end

#put?Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/sidemash/sdk/http_method.rb', line 99

def put?
  @value == 'PUT'
end

#to_json(*a) ⇒ Object



111
112
113
# File 'lib/sidemash/sdk/http_method.rb', line 111

def to_json(*a)
  @value
end

#to_sObject



115
116
117
# File 'lib/sidemash/sdk/http_method.rb', line 115

def to_s
  @value
end