Class: ActiveFedora::LdpResourceService
- Inherits:
-
Object
- Object
- ActiveFedora::LdpResourceService
- Defined in:
- lib/active_fedora/ldp_resource_service.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #build(klass, id) ⇒ Object
- #build_resource_under_path(graph, parent_uri) ⇒ Object
-
#initialize(conn) ⇒ LdpResourceService
constructor
A new instance of LdpResourceService.
- #resource_klass(klass) ⇒ Object
- #update(change_set, klass, id) ⇒ Object
Constructor Details
#initialize(conn) ⇒ LdpResourceService
5 6 7 |
# File 'lib/active_fedora/ldp_resource_service.rb', line 5 def initialize(conn) @connection = conn end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
3 4 5 |
# File 'lib/active_fedora/ldp_resource_service.rb', line 3 def connection @connection end |
Instance Method Details
#build(klass, id) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/active_fedora/ldp_resource_service.rb', line 9 def build(klass, id) resource_klass = resource_klass(klass) if id resource_klass.new(connection, to_uri(klass, id)) else parent_uri = ActiveFedora.fedora.host + ActiveFedora.fedora.base_path resource_klass.new(connection, nil, nil, parent_uri) end end |
#build_resource_under_path(graph, parent_uri) ⇒ Object
29 30 31 32 |
# File 'lib/active_fedora/ldp_resource_service.rb', line 29 def build_resource_under_path(graph, parent_uri) parent_uri ||= ActiveFedora.fedora.host + ActiveFedora.fedora.base_path LdpResource.new(connection, nil, graph, parent_uri) end |
#resource_klass(klass) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/active_fedora/ldp_resource_service.rb', line 19 def resource_klass(klass) if klass <= ActiveFedora::IndirectContainer IndirectContainerResource elsif klass <= ActiveFedora::DirectContainer DirectContainerResource else LdpResource end end |
#update(change_set, klass, id) ⇒ Object
34 35 36 |
# File 'lib/active_fedora/ldp_resource_service.rb', line 34 def update(change_set, klass, id) SparqlInsert.new(change_set.changes).execute(to_uri(klass, id)) end |