Class: Azeroth::Decorator::MethodBuilder Private
- Inherits:
-
Sinclair
- Object
- Sinclair
- Azeroth::Decorator::MethodBuilder
- Defined in:
- lib/azeroth/decorator/method_builder.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Responsible for building readers for attributes
Class Method Summary collapse
-
.build_reader(klass, attribute, options) ⇒ Array<Sinclair::MethodDefinition>
private
Builds reader.
Instance Method Summary collapse
-
#build_reader(attribute) ⇒ Array<Sinclair::MethodDefinition>
private
Builds reader.
-
#initialize(klass, options) ⇒ MethodBuilder
constructor
private
A new instance of MethodBuilder.
- #skip_creation?(attribute) ⇒ Boolean private
Constructor Details
#initialize(klass, options) ⇒ MethodBuilder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of MethodBuilder.
21 22 23 24 |
# File 'lib/azeroth/decorator/method_builder.rb', line 21 def initialize(klass, ) super(klass) @options = end |
Class Method Details
.build_reader(klass, attribute, options) ⇒ Array<Sinclair::MethodDefinition>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Builds reader
reaader delegate method calls to @object
16 17 18 |
# File 'lib/azeroth/decorator/method_builder.rb', line 16 def build_reader(klass, attribute, ) new(klass, ).build_reader(attribute) end |
Instance Method Details
#build_reader(attribute) ⇒ Array<Sinclair::MethodDefinition>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Builds reader
reaader delegate method calls to @object
27 28 29 30 31 32 |
# File 'lib/azeroth/decorator/method_builder.rb', line 27 def build_reader(attribute) return if skip_creation?(attribute) add_method(attribute, "@object.#{attribute}") build end |
#skip_creation?(attribute) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 37 38 39 |
# File 'lib/azeroth/decorator/method_builder.rb', line 34 def skip_creation?(attribute) return true unless .reader return false unless klass.method_defined?(attribute) !.override end |