Class: InferredCrumpets::Builder
- Inherits:
-
Object
- Object
- InferredCrumpets::Builder
- Defined in:
- lib/inferred_crumpets/builder.rb
Instance Attribute Summary collapse
-
#parents ⇒ Object
readonly
Returns the value of attribute parents.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
-
#view_context ⇒ Object
readonly
Returns the value of attribute view_context.
Class Method Summary collapse
- .build_all!(view_context, subject, parents = []) ⇒ Object
- .build_inferred_crumbs!(view_context) ⇒ Object
- .build_single!(view_context, subject) ⇒ Object
Instance Method Summary collapse
- #build_all! ⇒ Object
- #build_single! ⇒ Object
-
#initialize(view_context, subject, parents = []) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(view_context, subject, parents = []) ⇒ Builder
Returns a new instance of Builder.
20 21 22 23 24 25 |
# File 'lib/inferred_crumpets/builder.rb', line 20 def initialize(view_context, subject, parents = []) @route_checker = RouteChecker.new(view_context) @view_context = view_context @subject = subject @parents = parents end |
Instance Attribute Details
#parents ⇒ Object (readonly)
Returns the value of attribute parents.
3 4 5 |
# File 'lib/inferred_crumpets/builder.rb', line 3 def parents @parents end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
3 4 5 |
# File 'lib/inferred_crumpets/builder.rb', line 3 def subject @subject end |
#view_context ⇒ Object (readonly)
Returns the value of attribute view_context.
3 4 5 |
# File 'lib/inferred_crumpets/builder.rb', line 3 def view_context @view_context end |
Class Method Details
.build_all!(view_context, subject, parents = []) ⇒ Object
12 13 14 |
# File 'lib/inferred_crumpets/builder.rb', line 12 def self.build_all!(view_context, subject, parents = []) new(view_context, subject, parents).build_all! end |
.build_inferred_crumbs!(view_context) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/inferred_crumpets/builder.rb', line 5 def self.build_inferred_crumbs!(view_context) subject = SubjectFinder.for_context(view_context) return unless subject parents = [view_context.parent_object].compact.flatten rescue [] build_all!(view_context, subject, parents) end |
.build_single!(view_context, subject) ⇒ Object
16 17 18 |
# File 'lib/inferred_crumpets/builder.rb', line 16 def self.build_single!(view_context, subject) new(view_context, subject).build_single! end |
Instance Method Details
#build_all! ⇒ Object
27 28 29 30 31 |
# File 'lib/inferred_crumpets/builder.rb', line 27 def build_all! build_crumbs_for_parents! build_crumb_for_collection! build_crumb_for_action! end |
#build_single! ⇒ Object
33 34 35 |
# File 'lib/inferred_crumpets/builder.rb', line 33 def build_single! build_crumb_for_subject! end |