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-1.1.8 lib/fedora/base.rb
active-fedora-1.1.7 lib/fedora/base.rb
active-fedora-1.1.6 lib/fedora/base.rb
active-fedora-1.1.5 lib/fedora/base.rb
active-fedora-1.1.4 lib/fedora/base.rb
active-fedora-1.1.4.pre2 lib/fedora/base.rb
active-fedora-1.1.2 lib/fedora/base.rb
active-fedora-1.1.1 lib/fedora/base.rb
active-fedora-1.1.0 lib/fedora/base.rb