Sha256: f6a1ef6bfc69f7e6fbfe565d3246deb49ab02f2573f31437a0d0c6c5064f0f36

Contents?: true

Size: 816 Bytes

Versions: 29

Compression:

Stored size: 816 Bytes

Contents

require 'xmlsimple'

class Hash
  #   {:q => 'test', :num => 5}.to_query # => 'q=test&num=5'
  #   let's avoid stomping on rails' version eh?
  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
  
  # == Parameters
  # attrs<Hash>:: 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

29 entries across 29 versions & 1 rubygems

Version Path
active-fedora-2.2.0 lib/fedora/base.rb
active-fedora-2.1.0 lib/fedora/base.rb
active-fedora-2.0.4 lib/fedora/base.rb
active-fedora-2.0.3 lib/fedora/base.rb
active-fedora-2.0.2 lib/fedora/base.rb
active-fedora-2.0.1 lib/fedora/base.rb
active-fedora-2.0.0 lib/fedora/base.rb
active-fedora-1.2.9 lib/fedora/base.rb
active-fedora-1.2.8 lib/fedora/base.rb
active-fedora-1.2.7 lib/fedora/base.rb
active-fedora-1.2.6 lib/fedora/base.rb
active-fedora-1.2.5 lib/fedora/base.rb
active-fedora-1.2.4 lib/fedora/base.rb
active-fedora-1.2.3 lib/fedora/base.rb
active-fedora-1.2.2 lib/fedora/base.rb
active-fedora-1.2.1 lib/fedora/base.rb
active-fedora-1.2.0 lib/fedora/base.rb
active-fedora-1.1.13 lib/fedora/base.rb
active-fedora-1.1.11 lib/fedora/base.rb
active-fedora-1.1.9 lib/fedora/base.rb