Class: LinkThumbnailer::Object
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- LinkThumbnailer::Object
show all
- Defined in:
- lib/link_thumbnailer/object.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/link_thumbnailer/object.rb', line 7
def method_missing(method_name, *args, &block)
method_name = method_name.to_s
if method_name.end_with?('?')
method_name.chop!
!self[method_name].nil?
else
self[method_name]
end
end
|
Instance Method Details
24
25
26
27
28
29
30
|
# File 'lib/link_thumbnailer/object.rb', line 24
def to_hash
if self.images.none? {|i| i.is_a?(String)}
super.merge('images' => self.images.map(&:to_hash))
else
super
end
end
|
32
33
34
35
36
37
38
|
# File 'lib/link_thumbnailer/object.rb', line 32
def to_json
if self.images.none? {|i| i.is_a?(String)}
JSON.generate(self.to_hash.merge('images' => self.images.map(&:to_hash)))
else
JSON.generate(self.to_hash)
end
end
|