-
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.
Add builder as a dependency and monkey patch into XmlMarkup class (#1)
- Added builder and request_store as dependencies - Monkey patched into Builder's XmlMarkup class
- Loading branch information
1 parent
958df82
commit 4c51f3e
Showing
3 changed files
with
50 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
builder_deferred_tagging (0.1.0) | ||
builder | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
builder (3.2.3) | ||
rake (10.5.0) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
builder_deferred_tagging! | ||
bundler (~> 2.0) | ||
rake (~> 10.0) | ||
|
||
BUNDLED WITH | ||
2.0.2 |
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 |
---|---|---|
|
@@ -8,16 +8,14 @@ Gem::Specification.new do |spec| | |
spec.authors = ["ConnorSheremeta"] | ||
spec.email = ["[email protected]"] | ||
|
||
spec.summary = %q{TODO: Write a short summary, because RubyGems requires one.} | ||
spec.description = %q{TODO: Write a longer description or delete this line.} | ||
spec.homepage = "TODO: Put your gem's website or public repo URL here." | ||
spec.summary = %q{This gem is used for deferred tagging through builder} | ||
spec.homepage = "https://github.com/ualbertalib/builder_deferred_tagging" | ||
spec.license = "MIT" | ||
|
||
spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'" | ||
|
||
spec.metadata["homepage_uri"] = spec.homepage | ||
spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here." | ||
spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." | ||
spec.metadata["source_code_uri"] = "https://github.com/ualbertalib/builder_deferred_tagging" | ||
|
||
# Specify which files should be added to the gem when it is released. | ||
# The `git ls-files -z` loads the files in the RubyGem that have been added into git. | ||
|
@@ -28,6 +26,9 @@ Gem::Specification.new do |spec| | |
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } | ||
spec.require_paths = ["lib"] | ||
|
||
spec.add_dependency "builder" | ||
spec.add_dependency "request_store" | ||
|
||
spec.add_development_dependency "bundler", "~> 2.0" | ||
spec.add_development_dependency "rake", "~> 10.0" | ||
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,6 +1,26 @@ | ||
require "builder_deferred_tagging/version" | ||
require "builder/xmlmarkup" | ||
require "request_store" | ||
|
||
module BuilderDeferredTagging | ||
class Error < StandardError; end | ||
# Your code goes here... | ||
Builder::XmlMarkup.class_eval do | ||
def push_deferred_attribute (attr) | ||
local_deferred_attributes.merge!(attr) | ||
end | ||
|
||
def deferred_attributes | ||
attr = local_deferred_attributes | ||
clear_local_deferred_attributes | ||
attr | ||
end | ||
|
||
private | ||
def local_deferred_attributes | ||
RequestStore.store[:deferred_attributes] ||= {} | ||
end | ||
|
||
def clear_local_deferred_attributes | ||
RequestStore.store[:deferred_attributes] = {} | ||
end | ||
end | ||
end |