Class: Amrita2::Filters::FilterArray

Inherits:
Array show all
Defined in:
lib/amrita2/template.rb

Overview

:nodoc: all

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ FilterArray

Returns a new instance of FilterArray.



2067
2068
2069
# File 'lib/amrita2/template.rb', line 2067

def initialize(*args)
  args.each { |a| self << a }
end

Instance Method Details

#|(other) ⇒ Object



2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
# File 'lib/amrita2/template.rb', line 2071

def |(other)
  case other
  when Class
    a = self + [other.new]
    FilterArray.new(*a)
  when Filters::Base
    a = self + [other]
    FilterArray.new(*a)
  when Symbol
    self + FilterArray.new(FunctionFilter.new(other))
  when Array
    case other.first
    when Symbol
      self + FilterArray.new(FunctionFilter.new(*other))
    else
      self + other
    end
  else
    raise "not filter #{other.inspect}"
  end
end