Class: Pakyow::Reflection::Scope Private
- Inherits:
-
Object
- Object
- Pakyow::Reflection::Scope
- Defined in:
- lib/pakyow/reflection/scope.rb
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.
Instance Attribute Summary collapse
- #actions ⇒ Object readonly private
- #children ⇒ Object readonly private
- #name ⇒ Object readonly private
- #parent ⇒ Object writeonly private
- #parents ⇒ Object readonly private
Instance Method Summary collapse
- #action(name) ⇒ Object private
- #add_attribute(attribute, type:) ⇒ Object private
- #add_parent(parent) ⇒ Object private
- #attribute(name, type:) ⇒ Object private
- #attributes ⇒ Object private
- #cleanup ⇒ Object private
-
#initialize(name) ⇒ Scope
constructor
private
A new instance of Scope.
- #named?(name) ⇒ Boolean private
- #plural_name ⇒ Object private
Constructor Details
#initialize(name) ⇒ Scope
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 Scope.
12 13 14 15 |
# File 'lib/pakyow/reflection/scope.rb', line 12 def initialize(name) @name = normalize(name) @parents, @actions, @attributes, @children = [], [], { form: [], view: [] }, [] end |
Instance Attribute Details
#actions ⇒ Object (readonly)
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.
9 10 11 |
# File 'lib/pakyow/reflection/scope.rb', line 9 def actions @actions end |
#children ⇒ Object (readonly)
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.
9 10 11 |
# File 'lib/pakyow/reflection/scope.rb', line 9 def children @children end |
#name ⇒ Object (readonly)
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.
9 10 11 |
# File 'lib/pakyow/reflection/scope.rb', line 9 def name @name end |
#parent=(value) ⇒ Object (writeonly)
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.
10 11 12 |
# File 'lib/pakyow/reflection/scope.rb', line 10 def parent=(value) @parent = value end |
#parents ⇒ Object (readonly)
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.
9 10 11 |
# File 'lib/pakyow/reflection/scope.rb', line 9 def parents @parents end |
Instance Method Details
#action(name) ⇒ Object
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.
28 29 30 31 32 |
# File 'lib/pakyow/reflection/scope.rb', line 28 def action(name) @actions.find { |action| action.named?(name) } end |
#add_attribute(attribute, type:) ⇒ Object
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.
40 41 42 |
# File 'lib/pakyow/reflection/scope.rb', line 40 def add_attribute(attribute, type:) @attributes[type] << attribute end |
#add_parent(parent) ⇒ Object
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.
17 18 19 20 21 22 |
# File 'lib/pakyow/reflection/scope.rb', line 17 def add_parent(parent) unless @parents.include?(parent) @parents << parent parent.children << self end end |
#attribute(name, type:) ⇒ Object
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 |
# File 'lib/pakyow/reflection/scope.rb', line 34 def attribute(name, type:) @attributes[type].find { |attribute| attribute.named?(name) } end |
#attributes ⇒ Object
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.
44 45 46 47 48 49 50 |
# File 'lib/pakyow/reflection/scope.rb', line 44 def attributes # TODO: In addition to finding view attributes, should we be finding view associations? # @attributes[:form].concat(@attributes[:view]).uniq { |attribute| attribute.name } end |
#cleanup ⇒ Object
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.
56 57 58 |
# File 'lib/pakyow/reflection/scope.rb', line 56 def cleanup @actions.each(&:cleanup) end |
#named?(name) ⇒ 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.
24 25 26 |
# File 'lib/pakyow/reflection/scope.rb', line 24 def named?(name) @name == normalize(name) end |
#plural_name ⇒ Object
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.
52 53 54 |
# File 'lib/pakyow/reflection/scope.rb', line 52 def plural_name Support.inflector.pluralize(@name).to_sym end |