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 # def an_allowed_method
# 'this comes from an allowed method' # 'this comes from an allowed method'
# end # end
#
# def unallowed_method # def unallowed_method
# 'this will never be an output' # 'this will never be an output'
# end # end
@@ -26,7 +27,7 @@
# 'and this from another allowed method' # 'and this from another allowed method'
# end # end
# end # end
# end #
# #
# usage: # usage:
# @something = SomeClass.new # @something = SomeClass.new
@@ -41,16 +42,18 @@
# association models. # association models.
# #
class Module class Module
def liquid_methods(*allowed_methods) def liquid_methods(*allowed_methods)
drop_class = eval "class #{self.to_s}::LiquidDropClass < Liquid::Drop; self; end" drop_class = eval "class #{self.to_s}::LiquidDropClass < Liquid::Drop; self; end"
define_method :to_liquid do define_method :to_liquid do
drop_class.new(self) drop_class.new(self)
end end
drop_class.class_eval do drop_class.class_eval do
def initialize(object) def initialize(object)
@object = object @object = object
end end
allowed_methods.each do |sym| allowed_methods.each do |sym|
define_method sym do define_method sym do
@object.send sym @object.send sym
@@ -58,5 +61,4 @@ class Module
end end
end end
end end
end end