Class: Roadie::Rails::Options
- Inherits:
-
Object
- Object
- Roadie::Rails::Options
- Defined in:
- lib/roadie/rails/options.rb
Instance Attribute Summary collapse
-
#after_transformation ⇒ Object
writeonly
Sets the attribute after_transformation.
-
#before_transformation ⇒ Object
writeonly
Sets the attribute before_transformation.
-
#keep_uninlinable_css ⇒ Object
writeonly
Sets the attribute keep_uninlinable_css.
-
#url_options ⇒ Object
writeonly
Sets the attribute url_options.
Instance Method Summary collapse
- #[](option) ⇒ Object
- #[]=(option, value) ⇒ Object
- #apply_to(document) ⇒ Object
- #asset_providers=(providers) ⇒ Object
- #combine(options) ⇒ Object
- #combine!(options) ⇒ Object
- #external_asset_providers=(providers) ⇒ Object
-
#initialize(options = {}) ⇒ Options
constructor
A new instance of Options.
- #merge(options) ⇒ Object
- #merge!(options) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Options
Returns a new instance of Options.
24 25 26 27 28 29 |
# File 'lib/roadie/rails/options.rb', line 24 def initialize( = {}) complain_about_unknown_keys .keys .each_pair do |name, value| self[name] = value end end |
Instance Attribute Details
#after_transformation=(value) ⇒ Object (writeonly)
Sets the attribute after_transformation
17 18 19 |
# File 'lib/roadie/rails/options.rb', line 17 def after_transformation=(value) @after_transformation = value end |
#before_transformation=(value) ⇒ Object (writeonly)
Sets the attribute before_transformation
17 18 19 |
# File 'lib/roadie/rails/options.rb', line 17 def before_transformation=(value) @before_transformation = value end |
#keep_uninlinable_css=(value) ⇒ Object (writeonly)
Sets the attribute keep_uninlinable_css
17 18 19 |
# File 'lib/roadie/rails/options.rb', line 17 def keep_uninlinable_css=(value) @keep_uninlinable_css = value end |
#url_options=(value) ⇒ Object (writeonly)
Sets the attribute url_options
17 18 19 |
# File 'lib/roadie/rails/options.rb', line 17 def (value) @url_options = value end |
Instance Method Details
#[](option) ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/roadie/rails/options.rb', line 99 def [](option) if ATTRIBUTE_NAMES.include?(option) public_send(option) else raise ArgumentError, "#{option.inspect} is not a valid option" end end |
#[]=(option, value) ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/roadie/rails/options.rb', line 107 def []=(option, value) if ATTRIBUTE_NAMES.include?(option) public_send(:"#{option}=", value) else raise ArgumentError, "#{option.inspect} is not a valid option" end end |
#apply_to(document) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/roadie/rails/options.rb', line 47 def apply_to(document) document. = document.before_transformation = before_transformation document.after_transformation = after_transformation document.asset_providers = asset_providers if asset_providers if external_asset_providers document.external_asset_providers = external_asset_providers end unless keep_uninlinable_css.nil? document.keep_uninlinable_css = keep_uninlinable_css end end |
#asset_providers=(providers) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/roadie/rails/options.rb', line 31 def asset_providers=(providers) # TODO: Raise an error when setting to nil in order to make this not a # silent error. if providers @asset_providers = ProviderList.wrap providers end end |
#combine(options) ⇒ Object
74 75 76 |
# File 'lib/roadie/rails/options.rb', line 74 def combine() dup.combine! end |
#combine!(options) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/roadie/rails/options.rb', line 78 def combine!() %i[after_transformation before_transformation].each do |name| self[name] = Utils.combine_callable(self[name], [name]) end %i[asset_providers external_asset_providers].each do |name| self[name] = Utils.combine_providers(self[name], [name]) end if .key?(:keep_uninlinable_css) self.keep_uninlinable_css = [:keep_uninlinable_css] end self. = Utils.combine_hash( , [:url_options] ) self end |
#external_asset_providers=(providers) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/roadie/rails/options.rb', line 39 def external_asset_providers=(providers) # TODO: Raise an error when setting to nil in order to make this not a # silent error. if providers @external_asset_providers = ProviderList.wrap providers end end |
#merge(options) ⇒ Object
63 64 65 |
# File 'lib/roadie/rails/options.rb', line 63 def merge() dup.merge! end |
#merge!(options) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/roadie/rails/options.rb', line 67 def merge!() ATTRIBUTE_NAMES.each do |attribute| self[attribute] = .fetch(attribute, self[attribute]) end self end |