Sha256: 395d72865a5f7ff83e8ff02a788d7769b626735c1c115742269d0d980d261bd8
Contents?: true
Size: 815 Bytes
Versions: 2
Compression:
Stored size: 815 Bytes
Contents
require 'forwardable' module Mumble class Model extend ::Forwardable class << self def attribute(name, &block) attributes << name define_method(name) do if block_given? self.instance_eval(&block) else @data[name.to_s] end end end def attributes @attributes ||= [] end end def initialize(client, data) @client = client @data = data end def update(data) @data.merge!(data) end def inspect attrs = self.class.attributes.map do |attr| [attr, send(attr)].join("=") end.join(" ") %Q{#<#{self.class.name} #{attrs}>} end protected def data @data end protected def client @client end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mumble-ruby-1.1.1 | lib/mumble-ruby/model.rb |
mumble-ruby-1.1.0 | lib/mumble-ruby/model.rb |