Module: Lafcadio::Query::DomainObjectImpostor
- Defined in:
- lib/lafcadio/query.rb
Overview
:nodoc:
Constant Summary collapse
- @@impostor_classes =
{}
Class Method Summary collapse
Class Method Details
.impostor(domain_class) ⇒ Object
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 |
# File 'lib/lafcadio/query.rb', line 497 def self.impostor( domain_class ) unless @@impostor_classes[domain_class] i_class = Class.new i_class.module_eval <<-CLASS_DEF attr_reader :domain_class def initialize; @domain_class = #{ domain_class.name }; end def method_missing( methId, *args ) fieldName = methId.id2name if ( classField = self.domain_class.field( fieldName ) ) ObjectFieldImpostor.new( self, classField ) else msg = "undefined method `" + fieldName + "' for #<DomainObjectImpostor::" + '#{ domain_class.name }' + ">" raise( NoMethodError, msg ) end end #{ domain_class.name }.class_fields.each do |class_field| begin undef_method class_field.name.to_sym rescue NameError # not defined globally or in an included Module, skip it end end CLASS_DEF @@impostor_classes[domain_class] = i_class end i_class = @@impostor_classes[domain_class] i_class.new end |