-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite Current and "class attributes" to remove AS dep
- Loading branch information
1 parent
af956e9
commit 311d67c
Showing
8 changed files
with
44 additions
and
37 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
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,28 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
Thread.attr_accessor :bridgetown_state | ||
|
||
module Bridgetown | ||
class Current < ActiveSupport::CurrentAttributes | ||
# @!method self.preloaded_configuration | ||
# @return [Bridgetown::Configuration] | ||
attribute :preloaded_configuration | ||
class Current | ||
class << self | ||
def thread_state = Thread.current.bridgetown_state ||= {} | ||
|
||
# @return [Bridgetown::Site, nil] | ||
def self.site | ||
sites[:main] | ||
end | ||
# @return [Bridgetown::Site, nil] | ||
def site = sites[:main] | ||
|
||
def self.site=(new_site) | ||
sites[:main] = new_site | ||
end | ||
def site=(new_site) | ||
sites[:main] = new_site | ||
end | ||
|
||
# @!method self.sites | ||
# @return [Hash<Symbol, Bridgetown::Site>] | ||
# @return [Hash<Symbol, Bridgetown::Site>] | ||
def sites | ||
thread_state[:sites] ||= {} | ||
end | ||
|
||
attribute :sites | ||
# @return [Bridgetown::Configuration] | ||
def preloaded_configuration = thread_state[:preloaded_configuration] | ||
|
||
def initialize | ||
super | ||
@attributes[:sites] = {} | ||
def preloaded_configuration=(value) | ||
thread_state[:preloaded_configuration] = value | ||
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
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