Class: Representable::Binding::Map

Inherits:
Array
  • Object
show all
Defined in:
lib/representable/binding.rb

Instance Method Summary collapse

Instance Method Details

#<<(binding) ⇒ Object

TODO: Merge with Definitions.



19
20
21
# File 'lib/representable/binding.rb', line 19

def <<(binding) # can be slow. this is compile time code.
  (existing = find { |bin| bin.name == binding.name }) ? self[index(existing)] = binding : super(binding)
end

#call(method, options) ⇒ Object



11
12
13
14
15
16
# File 'lib/representable/binding.rb', line 11

def call(method, options)
  each do |bin|
    options[:binding] = bin # this is so much faster than options.merge().
    bin.send(method, options)
  end
end