Class: ForemLite::Article

Inherits:
Object
  • Object
show all
Defined in:
lib/forem_lite/article.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Article

Article Initializer



10
11
12
# File 'lib/forem_lite/article.rb', line 10

def initialize(options)
  @raw = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ String, Object

Intercept NoMethodError exceptions and handle gracefully.



23
24
25
26
27
28
29
# 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

Instance Attribute Details

#rawObject

Returns the value of attribute raw.



3
4
5
# File 'lib/forem_lite/article.rb', line 3

def raw
  @raw
end

Instance Method Details

#respond_to?(method_sym, include_private = false) ⇒ Boolean, Object

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



39
40
41
42
43
44
45
# 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