class Mastodon::Base

Attributes

attributes[R]
to_h[R]
to_hash[R]

Public Class Methods

collection_attr_reader(attribute, klass) click to toggle source
# File lib/mastodon/base.rb, line 25
def collection_attr_reader(attribute, klass)
  define_method(attribute) do
    Mastodon::Collection.new(@attributes[attribute.to_s], klass)
  end
end
define_attribute_method(key) click to toggle source
# File lib/mastodon/base.rb, line 43
def define_attribute_method(key)
  define_method(key) do
    @attributes[key.to_s]
  end
end
define_predicate_method(key) click to toggle source
# File lib/mastodon/base.rb, line 37
def define_predicate_method(key)
  define_method("#{key}?") do
    @attributes[key.to_s]
  end
end
new(attributes = {}) click to toggle source
# File lib/mastodon/base.rb, line 8
def initialize(attributes = {})
  @attributes = attributes
end
normal_attr_reader(*attributes) click to toggle source
# File lib/mastodon/base.rb, line 13
def normal_attr_reader(*attributes)
  attributes.each do |attribute|
    define_attribute_method(attribute)
  end
end
object_attr_reader(attribute, klass) click to toggle source
# File lib/mastodon/base.rb, line 19
def object_attr_reader(attribute, klass)
  define_method(attribute) do
    klass.new(@attributes[attribute.to_s])
  end
end
predicate_attr_reader(*attributes) click to toggle source
# File lib/mastodon/base.rb, line 31
def predicate_attr_reader(*attributes)
  attributes.each do |attribute|
    define_predicate_method(attribute)
  end
end