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 27 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 45 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 39 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 10 def initialize(attributes = {}) @attributes = attributes end
normal_attr_reader(*attributes)
click to toggle source
# File lib/mastodon/base.rb, line 15 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 21 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 33 def predicate_attr_reader(*attributes) attributes.each do |attribute| define_predicate_method(attribute) end end