Class: Arrest::SingleResource
- Inherits:
-
RootResource
- Object
- AbstractResource
- RootResource
- Arrest::SingleResource
- Defined in:
- lib/arrest/single_resource.rb
Overview
A resource that does not maintain a collection of object but a single object.
Instance Attribute Summary
Attributes inherited from AbstractResource
Attributes included from HasAttributes
Class Method Summary collapse
Instance Method Summary collapse
-
#resource_location ⇒ Object
the single resource does not use an id to identify the object since it’s already identified by the reource path.
Methods inherited from RootResource
all, by_url, delete_all, filter, first, last, resource_path, #resource_path, scope, scoped_path, stub
Methods inherited from AbstractResource
#==, active_resource_classes, all_filters, body_root, build, #clone, #curl, custom_json_type, custom_resource_name, #delete, filters, inherited, #initialize, json_type_map, json_type_to_class, mk_proxy, #new_record?, parent, read_only_attributes, #reload, resource_name, #save, #save!, scope, source, to_json_type, #to_json_type
Methods included from BelongsTo
Methods included from HasView
Methods included from HasAttributes
#attributes, #attributes=, included, #init_from_hash, #initialize, #initialize_has_attributes, #load_from_stub, #render_field_to_hash?, #reset_dirtiness, #stubbed?, #to_hash, #to_jhash, #update_attributes
Methods included from HasMany
Constructor Details
This class inherits a constructor from Arrest::AbstractResource
Class Method Details
.find(context, id) ⇒ Object
16 17 18 |
# File 'lib/arrest/single_resource.rb', line 16 def find(context, id) raise "A find is not possible for a SingleResource" end |
.load(context) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/arrest/single_resource.rb', line 6 def load(context) r = source().get(context, "#{self.resource_path}") body = body_root(r) if body == nil || body.empty? Arrest::logger.info "SpecifiedDocumentNotFoundError for #{self.resource_path}" raise Errors::SpecifiedDocumentNotFoundError.new(nil, self.class) end self.build(context, body) end |
Instance Method Details
#resource_location ⇒ Object
the single resource does not use an id to identify the object since it’s already identified by the reource path
23 24 25 |
# File 'lib/arrest/single_resource.rb', line 23 def resource_location self.class.resource_path end |