Module: FedoraLens::Core

Extended by:
ActiveSupport::Concern
Defined in:
lib/fedora_lens/core.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#deleteObject


87
88
89
# File 'lib/fedora_lens/core.rb', line 87

def delete
  @orm.resource.delete
end

#errorsObject


71
72
73
74
75
76
# File 'lib/fedora_lens/core.rb', line 71

def errors
  obj = Object.new
  def obj.[](key)         [] end
  def obj.full_messages() [] end
  obj
end

#idObject


107
108
109
# File 'lib/fedora_lens/core.rb', line 107

def id
  self.class.uri_to_id(URI.parse(uri)) if uri.present?
end

#initialize(subject_or_data = {}, data = nil) ⇒ Object


65
66
67
# File 'lib/fedora_lens/core.rb', line 65

def initialize(subject_or_data = {}, data = nil)
  init_core(subject_or_data, data)
end

#new_record?Boolean

Returns:

  • (Boolean)

99
100
101
# File 'lib/fedora_lens/core.rb', line 99

def new_record?
  @orm.resource.new?
end

#persisted?Boolean

Returns:

  • (Boolean)

69
# File 'lib/fedora_lens/core.rb', line 69

def persisted?()      false end

#read_attribute_for_validation(key) ⇒ Object


78
79
80
# File 'lib/fedora_lens/core.rb', line 78

def read_attribute_for_validation(key)
  @attributes[key]
end

#reloadObject


82
83
84
85
# File 'lib/fedora_lens/core.rb', line 82

def reload
  @orm = @orm.reload
  @attributes = get_attributes_from_orm(@orm)
end

#saveObject


91
92
93
# File 'lib/fedora_lens/core.rb', line 91

def save
  new_record? ? create_record : update_record
end

#save!Object


95
96
97
# File 'lib/fedora_lens/core.rb', line 95

def save!
  save || raise(RecordNotSaved)
end

#uriObject


103
104
105
# File 'lib/fedora_lens/core.rb', line 103

def uri
  @orm.try(:resource).try(:subject_uri).try(:to_s)
end