Class: RGeo::Feature::MixinCollection::TypeData
- Inherits:
-
Object
- Object
- RGeo::Feature::MixinCollection::TypeData
- Defined in:
- lib/rgeo/feature/mixins.rb
Overview
An API point controlling a particular type.
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
The MixinCollection owning this data.
-
#type ⇒ Object
readonly
The feature type.
Instance Method Summary collapse
-
#_radd(module_) ⇒ Object
:nodoc:.
-
#add(module_) ⇒ Object
Add a mixin to be included in implementations of this type.
-
#include_in_class(klass_, include_ancestry_ = false) ⇒ Object
A class that implements this type should call this method to get the appropriate mixins.
-
#include_in_object(obj_, include_ancestry_ = false) ⇒ Object
An object that implements this type should call this method to get the appropriate mixins.
-
#initialize(collection_, type_) ⇒ TypeData
constructor
:nodoc:.
Constructor Details
#initialize(collection_, type_) ⇒ TypeData
:nodoc:
41 42 43 44 45 46 47 48 |
# File 'lib/rgeo/feature/mixins.rb', line 41 def initialize(collection_, type_) # :nodoc: @collection = collection_ @type = type_ @mixins = [] @classes = [] @rmixins = [] @rclasses = [] end |
Instance Attribute Details
#collection ⇒ Object (readonly)
The MixinCollection owning this data
54 55 56 |
# File 'lib/rgeo/feature/mixins.rb', line 54 def collection @collection end |
#type ⇒ Object (readonly)
The feature type
51 52 53 |
# File 'lib/rgeo/feature/mixins.rb', line 51 def type @type end |
Instance Method Details
#_radd(module_) ⇒ Object
:nodoc:
85 86 87 88 89 90 |
# File 'lib/rgeo/feature/mixins.rb', line 85 def _radd(module_) # :nodoc: @rmixins << module_ @rclasses.each { |k_| k_.class_eval { include(module_) } } @type.each_immediate_subtype { |t_| @collection.for_type(t_)._radd(module_) } self end |
#add(module_) ⇒ Object
Add a mixin to be included in implementations of this type.
58 59 60 61 62 |
# File 'lib/rgeo/feature/mixins.rb', line 58 def add(module_) @mixins << module_ @classes.each { |k_| k_.class_eval { include(module_) } } _radd(module_) end |
#include_in_class(klass_, include_ancestry_ = false) ⇒ Object
A class that implements this type should call this method to get the appropriate mixins. If include_ancestry_ is set to true, then mixins connected to subtypes of this type are also added to the class.
69 70 71 72 73 |
# File 'lib/rgeo/feature/mixins.rb', line 69 def include_in_class(klass_, include_ancestry_ = false) (include_ancestry_ ? @rmixins : @mixins).each { |m_| klass_.class_eval { include(m_) } } (include_ancestry_ ? @rclasses : @classes) << klass_ self end |
#include_in_object(obj_, include_ancestry_ = false) ⇒ Object
An object that implements this type should call this method to get the appropriate mixins. If include_ancestry_ is set to true, then mixins connected to subtypes of this type are also added to the object.
80 81 82 83 |
# File 'lib/rgeo/feature/mixins.rb', line 80 def include_in_object(obj_, include_ancestry_ = false) (include_ancestry_ ? @rmixins : @mixins).each { |m_| obj_.extend(m_) } self end |