mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-29 15:15:19 -07:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user