Class: TaliaCore::SourceTransferObject

Inherits:
Object
  • Object
show all
Defined in:
lib/talia_core/source_transfer_object.rb

Overview

Transfer Object Pattern implementation. It’s required by source administration panel, in order to normalize the values transportation between view and controller layers.

RDF objects (triple endpoint), could be a Source or a String.

java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html java.sun.com/blueprints/patterns/TransferObject.html

TODO: Remove as part of old admin interface?

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_or_uri) ⇒ SourceTransferObject

:nodoc:



15
16
17
18
19
20
21
22
# File 'lib/talia_core/source_transfer_object.rb', line 15

def initialize(name_or_uri) #:nodoc:
  @uri, @name = if /http:\/\//.match name_or_uri
    uri = N::URI.new(name_or_uri)
    [uri, uri.local_name]
  else
    [nil, name_or_uri]
  end
end

Instance Attribute Details

#uriObject (readonly)

:nodoc:



13
14
15
# File 'lib/talia_core/source_transfer_object.rb', line 13

def uri
  @uri
end

Instance Method Details

#idObject



24
25
26
# File 'lib/talia_core/source_transfer_object.rb', line 24

def id
  @name
end

#source?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/talia_core/source_transfer_object.rb', line 28

def source?
  !uri.blank?
end

#titleizedObject

:nodoc:



32
33
34
# File 'lib/talia_core/source_transfer_object.rb', line 32

def titleized #:nodoc:
  @name.titleize
end

#to_sObject

:nodoc:



36
37
38
# File 'lib/talia_core/source_transfer_object.rb', line 36

def to_s #:nodoc:
  (uri || @name).to_s
end