class Mumble::Model

Attributes

client[R]
data[R]

Public Class Methods

attribute(name, &block) click to toggle source
# File lib/mumble-ruby2/model.rb, line 8
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
attributes() click to toggle source
# File lib/mumble-ruby2/model.rb, line 19
def attributes
  @attributes ||= []
end
new(client, data) click to toggle source
# File lib/mumble-ruby2/model.rb, line 24
def initialize(client, data)
  @client = client
  @data   = data
end

Public Instance Methods

inspect() click to toggle source
# File lib/mumble-ruby2/model.rb, line 33
def inspect
  attrs = self.class.attributes.map do |attr|
    [attr, send(attr)].join("=")
  end.join(" ")
  %Q{#<#{self.class.name} #{attrs}>}
end
update(data) click to toggle source
# File lib/mumble-ruby2/model.rb, line 29
def update(data)
  @data.merge!(data)
end