module Eapi::List

Public Class Methods

add_features(klass) click to toggle source
# File lib/eapi/list.rb, line 13
def self.add_features(klass)
  Eapi::Common.add_features klass
  klass.extend(ClassMethods)
  klass.include(Eapi::Methods::Properties::ListInstanceMethods)
  klass.extend(Eapi::Methods::Properties::ListCLassMethods)
end
extended(mod) click to toggle source
# File lib/eapi/list.rb, line 20
def self.extended(mod)
  def mod.included(klass)
    Eapi::List.add_features klass
  end
end
included(klass) click to toggle source
# File lib/eapi/list.rb, line 26
def self.included(klass)
  Eapi::List.add_features klass
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/eapi/list.rb, line 47
def <=>(other)
  (_list <=> other) || (other.respond_to?(:_list) && _list <=> other._list)
end
_list() click to toggle source
# File lib/eapi/list.rb, line 38
def _list
  @_list ||= []
end
add(value) click to toggle source
# File lib/eapi/list.rb, line 42
def add(value)
  self << value
  self
end
is_multiple?() click to toggle source
# File lib/eapi/list.rb, line 30
def is_multiple?
  true
end
to_a() click to toggle source
# File lib/eapi/list.rb, line 34
def to_a
  render
end

Protected Instance Methods

initialize_copy(other_ary) click to toggle source

ary.replace(other_ary) -> ary ary.initialize_copy(other_ary) -> ary

Replaces the contents of self with the contents of other_ary, truncating or expanding if necessary.

a = [ "a", "b", "c", "d", "e" ]
a.replace([ "x", "y", "z" ])   #=> ["x", "y", "z"]
a                              #=> ["x", "y", "z"]
# File lib/eapi/list.rb, line 62
def initialize_copy(other_ary)
  if other_ary.kind_of? List
    @_list = other_ary._list.dup
  elsif other_ary.respond_to? :to_a
    @_list = other_ary.to_a
  else
    raise ArgumentError, 'must be either a List or respond to `to_a`'
  end
end

Private Instance Methods

perform_before_validation() click to toggle source
# File lib/eapi/list.rb, line 82
def perform_before_validation
  if self.class.prepare_value_for_elements?
    _list.map! { |v| prepare_value_for_element(v) }
  end
end
perform_render() click to toggle source
# File lib/eapi/list.rb, line 75
def perform_render
  _list.reduce([]) do |array, value|
    set_value_in_final_array(array, value)
    array
  end
end