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