-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Tonksthebear/properly-mix-overwritten-cla…
…sses-with-non-overwritten-classes Properly mix overwritten classes with non overwritten classes
- Loading branch information
Showing
14 changed files
with
128 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Classy | ||
module Yaml | ||
VERSION = '1.2.1' | ||
VERSION = '1.3.0' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
class ApplicationComponent < ViewComponent::Base | ||
include Classy::Yaml::ComponentHelpers | ||
attr_reader :class_count | ||
|
||
def initialize(classy:, inherited: false) | ||
@classy = classy | ||
@inherited = inherited | ||
end | ||
|
||
def inherited_classes | ||
@inherited_classes ||= yass(@classy) | ||
end | ||
|
||
def class_count | ||
@class_count ||= @inherited ? inherited_classes&.split(' ')&.length : classes&.split(' ').length | ||
end | ||
|
||
def inherited_call | ||
yass(@classy) | ||
inherited_classes | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,24 @@ | ||
class TestComponent < ApplicationComponent | ||
def before_render | ||
@classes = @inherited ? inherited_call : yass(@classy) | ||
@class_count = @classes.split(' ').length | ||
end | ||
|
||
def classes | ||
@classes ||= @inherited ? inherited_classes : yass(@classy) | ||
end | ||
|
||
def call | ||
@inherited ? inherited_call : yass(@classy) | ||
@inherited ? inherited_call : classes | ||
end | ||
|
||
class NestedComponent < TestComponent | ||
def classes | ||
@classes ||= @inherited ? inherited_classes : yass(@classy) | ||
end | ||
|
||
def call | ||
@inherited ? inherited_call : yass(@classy) | ||
@inherited ? inherited_call : classes | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
engine_no_override: "engine-no-override-class" | ||
engine_default_override: "override-this" | ||
engine_extra_override: "override-this" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
extra_single: "extra-single-class" | ||
engine_extra_override: "extra-overidden-class" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters