class Gecko::BaseDecorator
Public Class Methods
new(delegate)
click to toggle source
# File lib/gecko/ext/liquid_compat.rb, line 42 def initialize(delegate) raise 'Turtles all the way down' if delegate.is_a?(BaseDecorator) @delegate = delegate end
Public Instance Methods
invokable_methods()
click to toggle source
Override Liquid::Drop#invokable_methods to add extra checks
# File lib/gecko/ext/liquid_compat.rb, line 70 def invokable_methods @invokable_methods ||= begin denylist = Gecko::Record::Base.public_instance_methods + Liquid::Drop.public_instance_methods denylist -= %i[to_liquid id created_at updated_at] allowlist = public_methods + @delegate.public_methods available_methods = (allowlist - denylist).map(&:to_s) available_methods.reject! { |method_name| method_name.ends_with?("=") } Set.new(available_methods) end end
invoke_drop(method_or_key)
click to toggle source
Override Liquid::Drop#invoke_drop to also check method arity
# File lib/gecko/ext/liquid_compat.rb, line 61 def invoke_drop(method_or_key) return unless invokable_methods.include?(method_or_key.to_s) && method_arity(method_or_key.to_sym) <= 0 public_send(method_or_key) end
Also aliased as: []
method_missing(method_name, *args, &block)
click to toggle source
Calls superclass method
# File lib/gecko/ext/liquid_compat.rb, line 48 def method_missing(method_name, *args, &block) if @delegate.respond_to?(method_name) @delegate.public_send(method_name, *args, &block) else super end end
respond_to_missing?(method_name, include_private = false)
click to toggle source
Calls superclass method
# File lib/gecko/ext/liquid_compat.rb, line 56 def respond_to_missing?(method_name, include_private = false) @delegate.respond_to?(method_name) || super end
Protected Instance Methods
client()
click to toggle source
# File lib/gecko/ext/liquid_compat.rb, line 91 def client @delegate.instance_variable_get(:@client) end
method_arity(method_name)
click to toggle source
# File lib/gecko/ext/liquid_compat.rb, line 83 def method_arity(method_name) if methods.include?(method_name) method(method_name).arity else @delegate.method(method_name).arity end end