Class: ExistDB::Resource::Base
- Inherits:
-
Object
- Object
- ExistDB::Resource::Base
- Extended by:
- ClassWrappingForwardable
- Defined in:
- lib/existdb/resource/base.rb
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(*opts) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
- #save ⇒ Object
Methods included from ClassWrappingForwardable
Constructor Details
#initialize(*opts) ⇒ Base
Returns a new instance of Base.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/existdb/resource/base.rb', line 34 def initialize(*opts) = Hash.new if opts.size == 1 and not opts.first.is_a?(Hash) then @obj = opts.first else opts.each do |opt| if opt.is_a?(Hash) then .merge!(opt) end end collection = ClassUnwrap[ [:parent] ] data = nil if [:binary] type = "BinaryResource" data = [:binary] elsif [:xml] type = "XMLResource" data = [:xml] else type = [:type] data = [:content] end type ||= "XMLResource" @obj = collection.createResource([:name], type) if data then self.content = data self.save end end end |
Instance Method Details
#delete ⇒ Object
78 79 80 |
# File 'lib/existdb/resource/base.rb', line 78 def delete parent.delete(self) end |
#inspect ⇒ Object
68 69 70 |
# File 'lib/existdb/resource/base.rb', line 68 def inspect "#<#{self.class}:0x#{self.hash.to_s(16)} name=#{self.name.inspect}>" end |
#save ⇒ Object
72 73 74 75 76 |
# File 'lib/existdb/resource/base.rb', line 72 def save collection = @obj.getParentCollection collection.storeResource( @obj ) true end |