Class: BaseDrop

Inherits:
Liquid::Drop
  • Object
show all
Defined in:
app/drops/base_drop.rb

Overview

– copyright ChiliProject is a project management system.

Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

See doc/COPYRIGHT.rdoc for more details. ++

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ BaseDrop

Returns a new instance of BaseDrop


16
17
18
# File 'app/drops/base_drop.rb', line 16

def initialize(object)
  @object = object unless object.respond_to?(:visible?) && !object.visible?
end

Class Method Details

.allowed_methods(*allowed_methods) ⇒ Object

Defines a Liquid method on the drop that is allowed to call the Ruby method directly. Best used for attributes.

Based on Module#liquid_methods


24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/drops/base_drop.rb', line 24

def self.allowed_methods(*allowed_methods)
  class_eval do
    allowed_methods.each do |sym|
      define_method sym do
        if @object.respond_to?(:public_send)
          @object.public_send(sym) rescue nil
        else
          @object.send(sym) rescue nil
        end
      end
    end
  end
end