Class: Drugbank::Base
- Inherits:
-
Object
- Object
- Drugbank::Base
- Defined in:
- lib/drugbank/base.rb
Direct Known Subclasses
AtcCode, Brand, Category, Dosage, Drug, DrugInteraction, Drugs, ExternalId, ExternalLink, Group, Manufacturer, Packager, Patent, Price, SecondaryAccessionNumber, Synonym
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/drugbank/base.rb', line 3 def method_missing(method, *args, &block) if self.attributes.keys.include?(method.to_s) self.class.send(:define_method, method,lambda{ self[method.to_s]}) return self[method.to_s] elsif self.relations.keys.include?(method.to_s) self.class.send(:define_method, method,lambda{ self.relations[method.to_s]}) return self.relations[method.to_s] else super end end |