Class: Earl::EntityBase
- Inherits:
-
HashInquirer
- Object
- Hash
- HashInquirer
- Earl::EntityBase
- Defined in:
- lib/earl/entity_base.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(source) ⇒ EntityBase
constructor
A new instance of EntityBase.
- #to_s ⇒ Object
Methods inherited from HashInquirer
Constructor Details
#initialize(source) ⇒ EntityBase
Returns a new instance of EntityBase.
3 4 5 |
# File 'lib/earl/entity_base.rb', line 3 def initialize( source ) super parser.parse( source ).resolve rescue raise InvalidURLError end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Earl::HashInquirer
Class Method Details
.part_accessor(*parts, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/earl/entity_base.rb', line 11 def self.part_accessor( *parts, &block ) parts.each do |part| define_method part do if self[ part ].is_a? String StringInquirer.new self[ part ] else self[ part ] end end define_method :"#{part}=" do |value| self[ part ] = value yield value if block_given? end end end |
Instance Method Details
#to_s ⇒ Object
7 8 9 |
# File 'lib/earl/entity_base.rb', line 7 def to_s assembler.assemble self end |