-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
275 additions
and
60 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
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 @@ | ||
class RailsOmnibar::HtmlController < RailsOmnibar::BaseController | ||
def show | ||
render html: omnibar.render | ||
render html: omnibar.render(self) | ||
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
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,27 @@ | ||
class RailsOmnibar | ||
def self.cast_to_condition(arg) | ||
case arg | ||
when nil, true, false then arg | ||
else | ||
arg.try(:arity) == 0 ? arg : RailsOmnibar.cast_to_proc(arg) | ||
end | ||
end | ||
|
||
def self.evaluate_condition(condition, context:, omnibar:) | ||
case condition | ||
when nil, true then true | ||
when false then false | ||
else | ||
context || raise(<<~EOS) | ||
Missing context for condition, please render the omnibar with `.render(self)` | ||
EOS | ||
if condition.try(:arity) == 0 | ||
context.instance_exec(&condition) | ||
elsif condition.respond_to?(:call) | ||
condition.call(context, controller: context, omnibar: omnibar) | ||
else | ||
raise("unsupported condition type: #{condition.class}") | ||
end | ||
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,9 @@ | ||
class RailsOmnibar | ||
def self.inherited(subclass) | ||
bar1 = singleton | ||
bar2 = subclass.send(:singleton) | ||
%i[@commands @config @items].each do |ivar| | ||
bar2.instance_variable_set(ivar, bar1.instance_variable_get(ivar).dup) | ||
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
Oops, something went wrong.