Class: InheritableAccessors::InheritableSet

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/inheritable_accessors/inheritable_set.rb

Constant Summary collapse

WRITE_METHODS =
%w{
  << add add? merge
}
REMOVE_METHODS =
%w{
  clear delete delete? delete_if keep_if reject! replace select!
}
READ_METHODS =
%w{
  & - < <= == > >= [] ^ classify difference disjoint? each empty? flatten
  include? inspect intersect? intersection length new proper_subset?
  proper_superset? size subset? subtract superset? to_a |
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prototype = nil) ⇒ InheritableSet

Returns a new instance of InheritableSet.



26
27
28
29
# File 'lib/inheritable_accessors/inheritable_set.rb', line 26

def initialize(prototype=nil)
  @__local_values__ = Set.new
  @__parent__ = prototype
end

Instance Attribute Details

#__local_values__Object

Returns the value of attribute local_values.



5
6
7
# File 'lib/inheritable_accessors/inheritable_set.rb', line 5

def __local_values__
  @__local_values__
end

#__parent__Object (readonly)

Returns the value of attribute __parent__.



6
7
8
# File 'lib/inheritable_accessors/inheritable_set.rb', line 6

def __parent__
  @__parent__
end

Instance Method Details

#inherit_copyObject Also known as: initialize_clone, initialize_dup



39
40
41
# File 'lib/inheritable_accessors/inheritable_set.rb', line 39

def inherit_copy
  InheritableSet.new(self)
end

#to_setObject



31
32
33
34
35
36
37
# File 'lib/inheritable_accessors/inheritable_set.rb', line 31

def to_set
  if !!__parent__
    __parent__.to_set | __local_values__
  else
    __local_values__.clone
  end
end