Sha256: 49a114e4bdfc4ea0a5c396cc7ba63fa8d97e3d88e1491ef32f8568546960f6db

Contents?: true

Size: 915 Bytes

Versions: 27

Compression:

Stored size: 915 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
  class SourceTransferObject
    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

27 entries across 27 versions & 1 rubygems

Version Path
talia_core-0.5.4 lib/talia_core/source_transfer_object.rb
talia_core-0.5.3 lib/talia_core/source_transfer_object.rb
talia_core-0.5.2 lib/talia_core/source_transfer_object.rb
talia_core-0.5.1 lib/talia_core/source_transfer_object.rb
talia_core-0.5.0 lib/talia_core/source_transfer_object.rb
talia_core-0.4.22 lib/talia_core/source_transfer_object.rb
talia_core-0.4.20 lib/talia_core/source_transfer_object.rb
talia_core-0.4.19 lib/talia_core/source_transfer_object.rb
talia_core-0.4.18 lib/talia_core/source_transfer_object.rb
talia_core-0.4.17 lib/talia_core/source_transfer_object.rb
talia_core-0.4.16 lib/talia_core/source_transfer_object.rb
talia_core-0.4.15 lib/talia_core/source_transfer_object.rb
talia_core-0.4.14 lib/talia_core/source_transfer_object.rb
talia_core-0.4.13 lib/talia_core/source_transfer_object.rb
talia_core-0.4.12 lib/talia_core/source_transfer_object.rb
talia_core-0.4.11 lib/talia_core/source_transfer_object.rb
talia_core-0.4.10 lib/talia_core/source_transfer_object.rb
talia_core-0.4.9 lib/talia_core/source_transfer_object.rb
talia_core-0.4.8 lib/talia_core/source_transfer_object.rb
talia_core-0.4.7 lib/talia_core/source_transfer_object.rb