Class: Proj::Session
- Inherits:
-
Object
- Object
- Proj::Session
- Defined in:
- lib/proj/session.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
-
#get_insert_statements(object, authority, code, numeric_codes = false, allowed_authorities = nil) ⇒ Strings
Returns SQL statements needed to insert the passed object into the database.
-
#initialize(context = nil) ⇒ Session
constructor
A new instance of Session.
- #to_ptr ⇒ Object
Constructor Details
#initialize(context = nil) ⇒ Session
Returns a new instance of Session.
12 13 14 15 16 |
# File 'lib/proj/session.rb', line 12 def initialize(context = nil) @context = context || Context.current @pointer = Api.proj_insert_object_session_create(@context) ObjectSpace.define_finalizer(self, self.class.finalize(@context, @pointer)) end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/proj/session.rb', line 3 def context @context end |
Instance Method Details
#get_insert_statements(object, authority, code, numeric_codes = false, allowed_authorities = nil) ⇒ Strings
Returns SQL statements needed to insert the passed object into the database.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/proj/session.rb', line 31 def get_insert_statements(object, , code, numeric_codes = false, = nil) = if # Add extra item at end for null pointer pointer = FFI::MemoryPointer.new(:pointer, .size + 1) # Convert strings to C chars .each_with_index do |, i| pointer.put_pointer(i, FFI::MemoryPointer.from_string()) end pointer end strings_ptr = Api.proj_get_insert_statements(self.context, self, object, , code, numeric_codes ? 1 : 0, , nil) Strings.new(strings_ptr) end |
#to_ptr ⇒ Object
18 19 20 |
# File 'lib/proj/session.rb', line 18 def to_ptr @pointer end |