Sha256: 7e83cb8b8ffa63563111855d6165e6769b43adea62ec1b86a92c5f846e172843
Contents?: true
Size: 727 Bytes
Versions: 1
Compression:
Stored size: 727 Bytes
Contents
require 'open-uri' require 'cymbal' module Linodians ## # Employee object class Employee def initialize(params = {}) @data = Cymbal.symbolize params @data.freeze end def photo @photo ||= open(PHOTO_URL % username) { |x| x.read } end def [](value) @data[value.to_sym] end def to_json(*args, &block) @data.to_json(*args, &block) end def respond_to?(method, _ = false) @data.key?(method) || super end def to_h @data.dup end private def method_missing(method, *args, &block) return super unless @data.key?(method) instance_eval "def #{method}() @data[:'#{method}'] end" send(method) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
linodians-1.0.0 | lib/linodians/employee.rb |