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


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

def delete
  @orm.resource.delete
end

#errorsObject


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

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

#idObject


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

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

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


56
57
58
# File 'lib/fedora_lens/core.rb', line 56

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

#new_record?Boolean

Returns:

  • (Boolean)

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

def new_record?
  @orm.resource.new?
end

#persisted?Boolean

Returns:

  • (Boolean)

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

def persisted?()      false end

#read_attribute_for_validation(key) ⇒ Object


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

def read_attribute_for_validation(key)
  @attributes[key]
end

#reloadObject


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

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

#saveObject


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

def save
  new_record? ? create_record : update_record
end

#save!Object


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

def save!
  save || raise(RecordNotSaved)
end

#uriObject


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

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