Method: Celerity::Element#initialize

Defined in:
lib/celerity/element.rb

#initialize(container, *args) ⇒ Element

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Element.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/celerity/element.rb', line 34

def initialize(container, *args)
  self.container = container

  case args.size
  when 2
    @conditions = { args[0] => args[1] }
  when 1
    if args.first.is_a? Hash
      @conditions = args.first
    elsif (how = self.class::DEFAULT_HOW)
      @conditions = { how => args.first }
    else
      raise ArgumentError, "wrong number of arguments (1 for 2)"
    end
  when 0
    @conditions = { :index => Celerity.index_offset }
  else
    raise ArgumentError, "wrong number of arguments (#{args.size} for 2)"
  end

  @conditions.freeze
  @object = nil
end