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 "attr_reader :domain_class\n\ndef initialize; @domain_class = \#{ domain_class.name }; end\n\ndef method_missing( methId, *args )\nfieldName = methId.id2name\nif ( classField = self.domain_class.field( fieldName ) )\nObjectFieldImpostor.new( self, classField )\nelse\nmsg = \"undefined method `\" + fieldName +\n\"' for #<DomainObjectImpostor::\" +\n'\#{ domain_class.name }' + \">\"\nraise( NoMethodError, msg )\nend\nend\n\n\#{ domain_class.name }.class_fields.each do |class_field|\nbegin\nundef_method class_field.name.to_sym\nrescue NameError\n# not defined globally or in an included Module, skip it\nend\nend\n" @@impostor_classes[domain_class] = i_class end i_class = @@impostor_classes[domain_class] i_class.new end |