Sha256: c2388d4becb1172c11afbfb29c8a15033793bee5f1ee5ce652dfa05ee4452732

Contents?: true

Size: 904 Bytes

Versions: 2

Compression:

Stored size: 904 Bytes

Contents

require 'redlander/storage'
require 'redlander/model_proxy'

module Redlander

  class Model

    include Redlander::ParsingInstanceMethods
    include Redlander::SerializingInstanceMethods

    attr_reader :rdf_model

    # Create a new RDF model.
    # For explanation of options, read Storage.initialize_storage
    def initialize(options = {})
      @rdf_storage = Storage.initialize_storage(options)

      @rdf_model = Redland.librdf_new_model(Redlander.rdf_world, @rdf_storage, "")
      raise RedlandError.new("Failed to create a new model") unless @rdf_model
      ObjectSpace.define_finalizer(@rdf_model, proc { Redland.librdf_free_model(@rdf_model) })
    end

    # Statements contained in the model.
    #
    # Similar to Ruby on Rails, a proxy object is actually returned,
    # which delegates methods to Statement class.
    def statements
      ModelProxy.new(self)
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redlander-0.2.2 lib/redlander/model.rb
redlander-0.2.1 lib/redlander/model.rb