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.



855
856
857
858
# File 'lib/lafcadio/objectStore.rb', line 855

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.



853
854
855
# File 'lib/lafcadio/objectStore.rb', line 853

def domain_class
  @domain_class
end

#row_hashObject (readonly)

Returns the value of attribute row_hash.



853
854
855
# File 'lib/lafcadio/objectStore.rb', line 853

def row_hash
  @row_hash
end

Instance Method Details

#[](key) ⇒ Object



860
861
862
863
864
865
866
867
868
869
870
871
# File 'lib/lafcadio/objectStore.rb', line 860

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



873
874
875
876
877
# File 'lib/lafcadio/objectStore.rb', line 873

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