Class: Valkyrie::Persistence::Fedora::Persister::OrmConverter::GraphToAttributes::Applicator
- Inherits:
-
Object
- Object
- Valkyrie::Persistence::Fedora::Persister::OrmConverter::GraphToAttributes::Applicator
show all
- Defined in:
- lib/valkyrie/persistence/fedora/persister/orm_converter.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(property) ⇒ Applicator
Returns a new instance of Applicator.
294
295
296
|
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 294
def initialize(property)
@property = property
end
|
Instance Attribute Details
#property ⇒ Object
Returns the value of attribute property.
291
292
293
|
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 291
def property
@property
end
|
Instance Method Details
#apply_to(hsh) ⇒ Object
298
299
300
301
302
|
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 298
def apply_to(hsh)
return if blacklist?(key)
hsh[key.to_sym] ||= []
hsh[key.to_sym] += cast_array(values)
end
|
#blacklist ⇒ Object
328
329
330
331
332
333
|
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 328
def blacklist
[
"http://fedora.info/definitions",
"http://www.iana.org/assignments/relation/last"
]
end
|
#blacklist?(key) ⇒ Boolean
313
314
315
316
317
318
|
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 313
def blacklist?(key)
blacklist.each do |blacklist_item|
return true if key.start_with?(blacklist_item)
end
false
end
|
#cast_array(values) ⇒ Object
320
321
322
323
324
325
326
|
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 320
def cast_array(values)
if values.is_a?(Time)
[values]
else
Array(values)
end
end
|
#key ⇒ Object
304
305
306
307
308
309
310
311
|
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 304
def key
predicate = statement.predicate.to_s
key = schema.property_for(resource: nil, predicate: predicate)
namespaces.each do |namespace|
key = key.to_s.gsub(/^#{namespace}/, '')
end
key
end
|
#namespaces ⇒ Object
335
336
337
338
339
340
|
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 335
def namespaces
[
"http://www.fedora.info/definitions/v4/",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
]
end
|
#values ⇒ Object
342
343
344
|
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 342
def values
statement.object
end
|