Class: FlatMap::BaseMapper
- Inherits:
-
Object
- Object
- FlatMap::BaseMapper
- Extended by:
- ActiveSupport::Autoload
- Includes:
- ActiveModel::Validations, AttributeMethods, Mapping, Mounting, Persistence, Skipping, Traits
- Defined in:
- lib/flat_map/base_mapper.rb
Overview
BaseMapper is an abstract class that hosts overwhelming majority of common functionality of EmptyMappers and Mappers.
For more detailed information on what mappers are, refer to Mapper documentation.
Direct Known Subclasses
Defined Under Namespace
Modules: AttributeMethods, Mapping, Mounting, Persistence, Skipping, Traits Classes: Factory
Instance Attribute Summary collapse
-
#host ⇒ FlatMap::Mapper
If mapper was mounted by another mapper, host is the one who mounted
self. -
#name ⇒ Object
Returns the value of attribute name.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#suffix ⇒ String?
suffixreader. -
#traits ⇒ Object
readonly
Returns the value of attribute traits.
Class Method Summary collapse
-
.inherited(subclass) ⇒ Object
Callback to dup mappings and mountings on inheritance.
Instance Method Summary collapse
-
#hosted? ⇒ Boolean
Return
trueif mapper is hosted, i.e. -
#initialize ⇒ BaseMapper
constructor
Raise exception on trying to initialize an instance.
-
#inspect ⇒ String
Return a simple string representation of
mapper. -
#owned? ⇒ Boolean
Return
trueifmapperis owned. -
#suffixed? ⇒ Boolean
Return
trueifsuffixis present.
Methods included from Skipping
#save, #shallow_save, #skip!, #skipped?, #use!, #valid?, #write
Methods included from Persistence
#apply, #errors, #save, #shallow_save, #valid?, #write
Methods included from AttributeMethods
Methods included from Traits
#extension, #extension?, #mountings, #self_mountings, #trait
Methods included from Mounting
#after_save_mountings, #before_save_mountings, #method_missing, #mounting, #mountings, #nearest_mountings, #read, #write
Methods included from Mapping
#[], #[]=, #mapping, #read, #write
Constructor Details
#initialize ⇒ BaseMapper
Raise exception on trying to initialize an instance.
44 45 46 |
# File 'lib/flat_map/base_mapper.rb', line 44 def initialize raise 'BaseMapper is abstract class and cannot be initialized' end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class FlatMap::BaseMapper::AttributeMethods
Instance Attribute Details
#host ⇒ FlatMap::Mapper
If mapper was mounted by another mapper, host is the one who mounted self.
69 70 71 |
# File 'lib/flat_map/base_mapper.rb', line 69 def host owned? ? owner.host : @host end |
#name ⇒ Object
Returns the value of attribute name.
27 28 29 |
# File 'lib/flat_map/base_mapper.rb', line 27 def name @name end |
#owner ⇒ Object
Returns the value of attribute owner.
27 28 29 |
# File 'lib/flat_map/base_mapper.rb', line 27 def owner @owner end |
#suffix ⇒ String?
suffix reader. Delegated to owner for owned mappers.
84 85 86 |
# File 'lib/flat_map/base_mapper.rb', line 84 def suffix owned? ? owner.suffix : @suffix end |
#traits ⇒ Object (readonly)
Returns the value of attribute traits.
25 26 27 |
# File 'lib/flat_map/base_mapper.rb', line 25 def traits @traits end |
Class Method Details
.inherited(subclass) ⇒ Object
36 37 38 39 |
# File 'lib/flat_map/base_mapper.rb', line 36 def self.inherited(subclass) subclass.mappings = mappings.dup subclass.mountings = mountings.dup end |
Instance Method Details
#hosted? ⇒ Boolean
Return true if mapper is hosted, i.e. it is mounted by another mapper.
77 78 79 |
# File 'lib/flat_map/base_mapper.rb', line 77 def hosted? host.present? end |
#inspect ⇒ String
Return a simple string representation of mapper. Done so to avoid really long inspection of internal objects (target - usually AR model, mountings and mappings)
52 53 54 |
# File 'lib/flat_map/base_mapper.rb', line 52 def inspect to_s end |
#owned? ⇒ Boolean
Return true if mapper is owned. This means that current mapper is actually a trait. Thus, it is a part of an owner mapper.
61 62 63 |
# File 'lib/flat_map/base_mapper.rb', line 61 def owned? owner.present? end |
#suffixed? ⇒ Boolean
Return true if suffix is present.
91 92 93 |
# File 'lib/flat_map/base_mapper.rb', line 91 def suffixed? suffix.present? end |