Class: RoadForest::Augment::Augmenter
- Inherits:
-
Object
- Object
- RoadForest::Augment::Augmenter
- Defined in:
- lib/roadforest/augment/augmenter.rb
Instance Attribute Summary collapse
-
#services ⇒ Object
readonly
Returns the value of attribute services.
Class Method Summary collapse
Instance Method Summary collapse
- #augment(graph) ⇒ Object
- #canonical_uri ⇒ Object
-
#initialize(services) ⇒ Augmenter
constructor
A new instance of Augmenter.
- #object_augmentations ⇒ Object
- #router ⇒ Object
- #subject_augmentations ⇒ Object
Constructor Details
#initialize(services) ⇒ Augmenter
Returns a new instance of Augmenter.
7 8 9 |
# File 'lib/roadforest/augment/augmenter.rb', line 7 def initialize(services) @services = services end |
Instance Attribute Details
#services ⇒ Object (readonly)
Returns the value of attribute services.
10 11 12 |
# File 'lib/roadforest/augment/augmenter.rb', line 10 def services @services end |
Class Method Details
.object_augmentations_registry ⇒ Object
24 25 26 |
# File 'lib/roadforest/augment/augmenter.rb', line 24 def self.object_augmentations_registry @object_registry ||= Utility::ClassRegistry.new(self, "object augmentation") end |
.subject_augmentations_registry ⇒ Object
20 21 22 |
# File 'lib/roadforest/augment/augmenter.rb', line 20 def self.subject_augmentations_registry @subject_registry ||= Utility::ClassRegistry.new(self, "subject augmentation") end |
Instance Method Details
#augment(graph) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/roadforest/augment/augmenter.rb', line 40 def augment(graph) augmenting = Augment::Process.new(graph) augmenting.subject_resources(router).each do |resource| subject_augmentations.each do |augmentation| augmentation.apply(resource) do |statement| augmenting.target_graph << statement end end end augmenting.object_resources(router).each do |resource| object_augmentations.each do |augmentation| augmentation.apply(resource) do |statement| augmenting.target_graph << statement end end end augmenting.target_graph end |
#canonical_uri ⇒ Object
16 17 18 |
# File 'lib/roadforest/augment/augmenter.rb', line 16 def canonical_uri @canonical_uri ||= Addressable::URI.parse(services.root_url) end |
#object_augmentations ⇒ Object
34 35 36 37 38 |
# File 'lib/roadforest/augment/augmenter.rb', line 34 def object_augmentations self.class.object_augmentations_registry.map_classes do |klass| klass.new(self) end end |
#router ⇒ Object
12 13 14 |
# File 'lib/roadforest/augment/augmenter.rb', line 12 def router services.router end |
#subject_augmentations ⇒ Object
28 29 30 31 32 |
# File 'lib/roadforest/augment/augmenter.rb', line 28 def subject_augmentations self.class.subject_augmentations_registry.map_classes do |klass| klass.new(self) end end |