Module: Wallaby::Baseable::ClassMethods
- Included in:
- ModelAuthorizer, ModelPaginator, ModelServicer, ResourceDecorator
- Defined in:
- lib/concerns/wallaby/baseable.rb
Overview
Configurable attributes:
-
mark a class as a base class
-
guess the model class if model class isn’t given
Instance Attribute Summary collapse
-
#base_class ⇒ Class
readonly
The base class or the one from super class.
- #model_class ⇒ Class?
Instance Method Summary collapse
-
#base_class! ⇒ Object
Mark the current class as the base class.
- #base_class? ⇒ true, false
- #namespace ⇒ Object deprecated Deprecated.
- #namespace=(_namespace) ⇒ Object deprecated Deprecated.
Instance Attribute Details
#base_class ⇒ Class (readonly)
Returns The base class or the one from super class.
25 26 27 |
# File 'lib/concerns/wallaby/baseable.rb', line 25 def base_class @base_class || superclass.try(:base_class) end |
#model_class ⇒ Class?
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/concerns/wallaby/baseable.rb', line 52 def model_class return if base_class? @model_class ||= Guesser.class_for(name) || raise( ClassNotFound, <<~INSTRUCTION The `model_class` hasn't been provided for Class `#{name}` and Wallaby cannot guess it right. If `#{name}` is supposed to be a base class, add the following line to its class declaration: class #{name} base_class! end Otherwise, please specify the `model_class` in `#{name}`'s declaration as follows: class #{name} self.model_class = CorrectModelClass end INSTRUCTION ) end |
Instance Method Details
#base_class! ⇒ Object
Mark the current class as the base class
19 20 21 |
# File 'lib/concerns/wallaby/baseable.rb', line 19 def base_class! @base_class = self end |
#base_class? ⇒ true, false
14 15 16 |
# File 'lib/concerns/wallaby/baseable.rb', line 14 def base_class? @base_class == self end |
#namespace ⇒ Object
Deprecated.
79 80 81 |
# File 'lib/concerns/wallaby/baseable.rb', line 79 def namespace Deprecator.alert method(__callee__), from: '0.3.0' end |
#namespace=(_namespace) ⇒ Object
Deprecated.
74 75 76 |
# File 'lib/concerns/wallaby/baseable.rb', line 74 def namespace=(_namespace) Deprecator.alert method(__callee__), from: '0.3.0' end |