Sha256: 844a82c9a51ee16f32d809d1600886b2a196b21ee1a712357fcc78f5757461c3
Contents?: true
Size: 679 Bytes
Versions: 2
Compression:
Stored size: 679 Bytes
Contents
module Zelda # Abstract base class to provide common functionality of Zelda importer classes. # including method_missing magic to turn an @attributes hash into getters. class Base def initialize(attributes={}) @attributes = {} attributes.each do |key, value| @attributes[key.to_sym] = value end end attr_reader :attributes # Try both string keys and symbol keys in that order. def method_missing(method, *args, &block) if @attributes[method] return @attributes[method] elsif @attributes.key?(method) return nil else super(method, *args, &block) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
zelda-1.1.1 | lib/zelda/base.rb |
zelda-1.1.0 | lib/zelda/base.rb |