Sha256: f8758ee56cbd316aa40cf27556f0d55749e25fbcef99342493d42528dbeae35b

Contents?: true

Size: 833 Bytes

Versions: 16

Compression:

Stored size: 833 Bytes

Contents

require 'xmlsimple'

class Hash
  
  # Produces a valid Fedora query based on the current hash
  # @example
  #   {:q => 'test', :num => 5}.to_fedora_query # => 'q=test&num=5'
  def to_fedora_query
    self.collect { |key, value| "#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}" }.sort * '&'
  end
  
  def self.from_xml(xml)
    XmlSimple.xml_in(xml, 'ForceArray' => false)
  end
end

class Fedora::BaseObject
  attr_accessor :attributes, :blob, :uri
  attr_reader :errors, :uri
  attr_writer :new_object
  
  # @param [Hash] attrs object attributes
  def initialize(attrs = {})
    @new_object = true
    @attributes = attrs || {}
    @errors = []
    @blob = attributes.delete(:blob)
    @repository = Fedora::Repository.instance
  end
  
  def [](key)
    @attributes[key]
  end
  
  def new_object?
    @new_object
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
active-fedora-3.0.7 lib/fedora/base.rb
active-fedora-3.0.6 lib/fedora/base.rb
active-fedora-3.0.5 lib/fedora/base.rb
active-fedora-2.3.8 lib/fedora/base.rb
active-fedora-3.0.4 lib/fedora/base.rb
active-fedora-3.0.3 lib/fedora/base.rb
active-fedora-3.0.1 lib/fedora/base.rb
active-fedora-3.0.0 lib/fedora/base.rb
active-fedora-2.3.7 lib/fedora/base.rb
active-fedora-2.3.4 lib/fedora/base.rb
active-fedora-2.3.3 lib/fedora/base.rb
active-fedora-2.3.1 lib/fedora/base.rb
active-fedora-2.3.0 lib/fedora/base.rb
active-fedora-2.2.3 lib/fedora/base.rb
active-fedora-2.2.2 lib/fedora/base.rb
active-fedora-2.2.1 lib/fedora/base.rb