Module: FedoraLens
- Extended by:
- ActiveSupport::Autoload, ActiveSupport::Concern
- Included in:
- TestClass
- Defined in:
- lib/fedora_lens.rb,
lib/fedora_lens/lens.rb,
lib/fedora_lens/errors.rb,
lib/fedora_lens/lenses.rb,
lib/fedora_lens/version.rb,
lib/fedora_lens/lens_tests.rb,
lib/fedora_lens/attribute_methods.rb,
lib/fedora_lens/attribute_methods/read.rb,
lib/fedora_lens/attribute_methods/write.rb,
lib/fedora_lens/attribute_methods/declarations.rb
Defined Under Namespace
Modules: AttributeMethods, ClassMethods, LensTests, Lenses
Classes: AttributeNotSupportedError, FedoraLensError, Lens, RecordNotSaved
Constant Summary
collapse
- HOST =
"http://localhost:8983/fedora/rest"
- VERSION =
'0.0.11'
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.base_path ⇒ Object
39
40
41
|
# File 'lib/fedora_lens.rb', line 39
def base_path
@@base_path ||= ''
end
|
.base_path=(path) ⇒ Object
Set a base path if you want to put all your objects below a certain path example:
FedoraLens.base_path = '/text
46
47
48
|
# File 'lib/fedora_lens.rb', line 46
def base_path= path
@@base_path = path
end
|
.connection ⇒ Object
31
32
33
|
# File 'lib/fedora_lens.rb', line 31
def connection
@@connection ||= Ldp::Client.new(host)
end
|
.host ⇒ Object
35
36
37
|
# File 'lib/fedora_lens.rb', line 35
def host
HOST
end
|
Instance Method Details
#delete ⇒ Object
92
93
94
|
# File 'lib/fedora_lens.rb', line 92
def delete
@orm.resource.delete
end
|
#errors ⇒ Object
76
77
78
79
80
81
|
# File 'lib/fedora_lens.rb', line 76
def errors
obj = Object.new
def obj.[](key) [] end
def obj.full_messages() [] end
obj
end
|
#id ⇒ Object
112
113
114
|
# File 'lib/fedora_lens.rb', line 112
def id
self.class.uri_to_id(URI.parse(uri)) if uri.present?
end
|
#initialize(subject_or_data = {}, data = nil) ⇒ Object
70
71
72
|
# File 'lib/fedora_lens.rb', line 70
def initialize(subject_or_data = {}, data = nil)
init_core(subject_or_data, data)
end
|
#new_record? ⇒ Boolean
104
105
106
|
# File 'lib/fedora_lens.rb', line 104
def new_record?
@orm.resource.new?
end
|
#persisted? ⇒ Boolean
74
|
# File 'lib/fedora_lens.rb', line 74
def persisted?() false end
|
#read_attribute_for_validation(key) ⇒ Object
83
84
85
|
# File 'lib/fedora_lens.rb', line 83
def read_attribute_for_validation(key)
@attributes[key]
end
|
#reload ⇒ Object
87
88
89
90
|
# File 'lib/fedora_lens.rb', line 87
def reload
@orm = @orm.reload
@attributes = get_attributes_from_orm(@orm)
end
|
#save ⇒ Object
96
97
98
|
# File 'lib/fedora_lens.rb', line 96
def save
new_record? ? create_record : update_record
end
|
#save! ⇒ Object
100
101
102
|
# File 'lib/fedora_lens.rb', line 100
def save!
save || raise(RecordNotSaved)
end
|
#uri ⇒ Object
108
109
110
|
# File 'lib/fedora_lens.rb', line 108
def uri
@orm.try(:resource).try(:subject_uri).try(:to_s)
end
|