Module: WADL::ResourceContainer

Included in:
Resource, Resources
Defined in:
lib/wadl/resource_container.rb

Overview

A mixin for objects that contain resources. If you include this, be sure to alias :find_resource to :find_resource_autogenerated beforehand.

Instance Method Summary (collapse)

Instance Method Details

- (Object) finalize_creation



49
50
51
52
53
54
# File 'lib/wadl/resource_container.rb', line 49

def finalize_creation
  resources.each { |r|
    define_singleton(r, :id,   :find_resource)
    define_singleton(r, :path, :find_resource_by_path)
  } if resources
end

- (Object) find_resource_by_path(path, auto_dereference = nil)



44
45
46
47
# File 'lib/wadl/resource_container.rb', line 44

def find_resource_by_path(path, auto_dereference = nil)
  path = path.to_s
  find_resource(auto_dereference) { |r| r.path == path }
end

- (Object) resource(name_or_id)



39
40
41
42
# File 'lib/wadl/resource_container.rb', line 39

def resource(name_or_id)
  name_or_id = name_or_id.to_s
  find_resource { |r| r.id == name_or_id || r.path == name_or_id }
end