class ForemLite::Article

Attributes

raw[RW]

Public Class Methods

new(options) click to toggle source

Article Initializer

@param [Hash] options <the article attributes returned by Forem>

# File lib/forem_lite/article.rb, line 10
def initialize(options)
  @raw = options
end

Public Instance Methods

method_missing(method_sym, *arguments, &block) click to toggle source

Intercept NoMethodError exceptions and handle gracefully.

@param [Symbol] method_sym <symbolized name of the method being called> @param [Hash] *arguments <the arguments passed in to this method. Can be any number, or none> @param [Object] &block <the block of the method called>

@return [String, Object] the method return value or NoMethodError

Calls superclass method
# File lib/forem_lite/article.rb, line 23
def method_missing(method_sym, *arguments, &block)
  if @raw&.keys&.include?(method_sym.to_s)
    @raw[method_sym.to_s]
  else
    super
  end
end
respond_to?(method_sym, include_private = false) click to toggle source

Hook method to return whether the obj can respond to id method or not.

@param [Symbol] method_sym <symbolized name of the method being called> @param [Boolean] include_private <indicates whether to include private methods in the search scope>

@return [Boolean, Object] <returns true if we can respond to the method, otherwise NoMethodError>

Calls superclass method
# File lib/forem_lite/article.rb, line 39
def respond_to?(method_sym, include_private = false)
  if @raw&.keys&.include?(method_sym.to_s)
    true
  else
    super
  end
end