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