Sha256: 0f67e5076237a6cb26c822692bb731c9bb110e284fbd4b3f2832b4fcaec1fde2

Contents?: true

Size: 978 Bytes

Versions: 1

Compression:

Stored size: 978 Bytes

Contents

module TaliaCore #:nodoc:
  # 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.
  #
  # http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html
  # http://java.sun.com/blueprints/patterns/TransferObject.html
  #
  # TODO: Remove as part of old admin interface?
  class SourceTransferObject # :nodoc:
    attr_reader :uri
    
    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
    
    def id
      @name
    end
    
    def source?
      !uri.blank?
    end
    
    def titleized #:nodoc:
      @name.titleize
    end
    
    def to_s #:nodoc:
      (uri || @name).to_s
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
talia_core-0.7.0 lib/talia_core/source_transfer_object.rb