Update module_ex.rb code documentation and code style

Didn't look good on rubydoc.info: http://i.imgur.com/469N92P.png
This commit is contained in:
Dorian Marié
2015-03-24 14:09:08 +01:00
parent 63eb1aac69
commit 23a23c6419
+5 -3
View File
@@ -13,6 +13,7 @@
# def an_allowed_method
# 'this comes from an allowed method'
# end
#
# def unallowed_method
# 'this will never be an output'
# end
@@ -26,7 +27,7 @@
# 'and this from another allowed method'
# end
# end
# end
#
#
# usage:
# @something = SomeClass.new
@@ -41,16 +42,18 @@
# association models.
#
class Module
def liquid_methods(*allowed_methods)
drop_class = eval "class #{self.to_s}::LiquidDropClass < Liquid::Drop; self; end"
define_method :to_liquid do
drop_class.new(self)
end
drop_class.class_eval do
def initialize(object)
@object = object
end
allowed_methods.each do |sym|
define_method sym do
@object.send sym
@@ -58,5 +61,4 @@ class Module
end
end
end
end