Class: EPIC::Resource

Inherits:
Object
  • Object
show all
Includes:
Rackful::Resource
Defined in:
src/epic_resource.rb

Overview

Base class of all resources in this web service.

Direct Known Subclasses

Collection, Generator, Handle, Profile

Constant Summary

GLOBAL_LOCK_MUTEX =
Mutex.new
GLOBAL_LOCK_HASH =
{}

Instance Attribute Summary

Attributes included from Rackful::Resource

#get_etag, #get_last_modified, #path

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from Rackful::Resource

#default_headers, #destroy, #do_METHOD, #empty?, #http_DELETE, #http_GET, #http_HEAD, #http_OPTIONS, #http_PUT, #http_method, #http_methods, included, #requested?, #serializer, #title, #to_rackful, #to_struct

Constructor Details

- (Resource) initialize(path)

A new instance of Resource

Parameters:

  • path (#to_s)

    The path of this resource. This is a `path-absolute` as defined in RFC3986, section 3.3.

See Also:

Since:

  • 0.0.1



86
87
88
# File 'src/epic_resource.rb', line 86

def initialize path
  self.path = path
end

Class Method Details

+ (void) lock(path, unlock)



101
102
103
104
105
106
107
108
109
110
111
# File 'src/epic_resource.rb', line 101

def self.lock path, unlock
  GLOBAL_LOCK_MUTEX.synchronize do
    if unlock
      GLOBAL_LOCK_HASH.delete path
    elsif GLOBAL_LOCK_HASH[path]
      raise HTTP503ServiceUnavailable, 'Another client is modifying the resource.'
    else
      GLOBAL_LOCK_HASH[path] = true
    end
  end
end

Instance Method Details

- (void) lock(unlock = false)



91
92
93
# File 'src/epic_resource.rb', line 91

def lock unlock = false
  self.class.lock self.path, unlock
end

- (void) unlock



96
97
98
# File 'src/epic_resource.rb', line 96

def unlock
  self.lock true
end

- (void) xhtml



114
# File 'src/epic_resource.rb', line 114

def xhtml; ''; end