Merge pull request #539 from Dorian/patch-1

Update module_ex.rb code documentation and code style
This commit is contained in:
Florian Weingarten
2015-03-24 15:21:22 +01:00
+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