Class: Idiomag::Articles
- Inherits:
-
Object
show all
- Defined in:
- lib/idiomag/articles.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/idiomag/articles.rb', line 25
def method_missing(method, *args)
case method
when :latest
get_latest if @latest.nil?
@latest
when :featured
get_featured if @featured.nil?
@featured
else
super
end
end
|
Instance Method Details
#get(*args) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/idiomag/articles.rb', line 3
def get(*args)
args.each do |action|
case action
when :latest
get_latest
when :featured
get_featured
else
raise ArgumentError
end
end
end
|
#respond_to?(method) ⇒ Boolean
16
17
18
19
20
21
22
23
|
# File 'lib/idiomag/articles.rb', line 16
def respond_to?(method)
case method
when :featured,:latest
true
else
super
end
end
|