Elastic objects in ruby

Here is an example of an elastic object wrapper in ruby

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class ElasticObject
attr_reader :object
alias_method :value, :object
def initialize(object)
@object = object
end
def method_missing(method, *args, &block)
return ElasticObject.new(object.send(method, *args, &block)) if object.respond_to?(method)
return ElasticObject.new(nil) if !object.is_a?(Hash)
result = [method] if key?(method)
result = [method.to_s] if key?(method.to_s)
return ElasticObject.new(result)
end
end
emp = ElasticObject.new({"name" => "Mujju", "age" => 1})
puts emp.dob.month # => nil
puts emp.name # => "Mujju"

I am currently working on Zammu which makes Automatic Deployment of static websites to Github Pages very easy. I would love to get your feedback on it, Use the invitation code KHAJA