Class: Webbed::Method
- Inherits:
-
Object
- Object
- Webbed::Method
- Defined in:
- lib/webbed/method.rb
Overview
Representation of an HTTP Method.
Constant Summary collapse
- DEFAULTS =
{ :safe => false, :idempotent => false, :allowable_entities => [:request, :response] }
- OPTIONS =
new('OPTIONS', :safe => true, :idempotent => true, :allowable_entities => [:response])
- GET =
new('GET', :safe => true, :idempotent => true, :allowable_entities => [:response])
- HEAD =
new('HEAD', :safe => true, :idempotent => true, :allowable_entities => [])
- POST =
new('POST', :safe => false, :idempotent => false, :allowable_entities => [:request, :response])
- PUT =
new('PUT', :safe => false, :idempotent => true, :allowable_entities => [:request, :response])
- DELETE =
new('DELETE', :safe => false, :idempotent => true, :allowable_entities => [:response])
- TRACE =
new('TRACE', :safe => true, :idempotent => true, :allowable_entities => [:response])
- CONNECT =
new('CONNECT', :safe => false, :idempotent => false, :allowable_entities => [:request, :response])
- PATCH =
new('PATCH', :safe => false, :idempotent => false, :allowable_entities => [:request, :response])
Instance Attribute Summary collapse
-
#allowable_entities ⇒ Array<:request, :response>
readonly
The allowable entities of a message.
Class Method Summary collapse
-
.new(value, options = {}) ⇒ Method
Checks for a cached Method or creates a new one.
Instance Method Summary collapse
-
#==(other_method) ⇒ Boolean
Compares the Method to another Method.
-
#idempotent? ⇒ Boolean
Whether or not the Method is idempotent.
-
#initialize(name, options = {}) ⇒ Method
constructor
Creates a new Method.
-
#safe? ⇒ Boolean
Whether or not the Method is safe.
-
#to_s ⇒ String
Converts the Method to a string.
Constructor Details
Instance Attribute Details
#allowable_entities ⇒ Array<:request, :response> (readonly)
The allowable entities of a message.
It can contain any combination of :request
and :response
.
15 16 17 |
# File 'lib/webbed/method.rb', line 15 def allowable_entities @allowable_entities end |
Class Method Details
.new(value, options = {}) ⇒ Method
Checks for a cached Method or creates a new one.
It caches the standard HTTP Methods that are in RFC 2616 as well as the
new method PATCH
. If the Method cannot be found, it calls #initialize
.
28 29 30 31 32 33 34 |
# File 'lib/webbed/method.rb', line 28 def self.new(value, = {}) if const_defined?(value) const_get(value) else super(value, ) end end |
Instance Method Details
#==(other_method) ⇒ Boolean
Compares the Method to another Method.
Two Methods are equal if they have the same name.
80 81 82 |
# File 'lib/webbed/method.rb', line 80 def ==(other_method) to_s == other_method.to_s end |
#idempotent? ⇒ Boolean
Whether or not the Method is idempotent.
63 64 65 |
# File 'lib/webbed/method.rb', line 63 def idempotent? @idempotent end |
#safe? ⇒ Boolean
Whether or not the Method is safe.
56 57 58 |
# File 'lib/webbed/method.rb', line 56 def safe? @safe end |
#to_s ⇒ String
Converts the Method to a string.
70 71 72 |
# File 'lib/webbed/method.rb', line 70 def to_s @name end |