Class: Lafcadio::ObjectStore::SqlToRubyValues

Inherits:
Object
  • Object
show all
Defined in:
lib/lafcadio/objectStore.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain_class, row_hash) ⇒ SqlToRubyValues

Returns a new instance of SqlToRubyValues.



819
820
821
822
# File 'lib/lafcadio/objectStore.rb', line 819

def initialize( domain_class, row_hash )
	@domain_class = domain_class
	@row_hash = row_hash
end

Instance Attribute Details

#domain_classObject (readonly)

Returns the value of attribute domain_class.



817
818
819
# File 'lib/lafcadio/objectStore.rb', line 817

def domain_class
  @domain_class
end

#row_hashObject (readonly)

Returns the value of attribute row_hash.



817
818
819
# File 'lib/lafcadio/objectStore.rb', line 817

def row_hash
  @row_hash
end

Instance Method Details

#[](key) ⇒ Object



824
825
826
827
828
829
830
831
832
833
834
835
# File 'lib/lafcadio/objectStore.rb', line 824

def []( key )
	if ( field = @domain_class.field key )
		val = field.value_from_sql( @row_hash[ field.db_field_name ] )
		if field.instance_of?( PrimaryKeyField ) && val.nil?
			raise FieldMatchError, error_msg, caller
		else
			val
		end
	else
		nil
	end
end

#error_msgObject



837
838
839
840
841
# File 'lib/lafcadio/objectStore.rb', line 837

def error_msg
	"The field \"" + @domain_class.sql_primary_key_name +
			"\" can\'t be found in the table \"" + 
			@domain_class.table_name + "\"."
end