Class: RailsBuild::Configuration
- Inherits:
-
Hash
- Object
- Hash
- RailsBuild::Configuration
- Defined in:
- lib/rails_build.rb
Constant Summary collapse
- ATTRS =
%w[ path trailing_slash force_ssl urls index_html ]
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #to_json(*args, **kws, &block) ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ Configuration
Returns a new instance of Configuration.
93 94 95 96 97 98 99 100 101 |
# File 'lib/rails_build.rb', line 93 def initialize(hash = {}) if hash.empty? hash = Configuration.defaults end hash.each{|attr, value| send("#{ attr }=", value)} Configuration.stringify_keys!(self) end |
Class Method Details
.defaults ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/rails_build.rb', line 71 def Configuration.defaults defaults = { path: RailsBuild.config_path, trailing_slash: (defined?(Rails) ? !!Rails.application.[:trailing_slash] : false), force_ssl: (defined?(Rails) ? !!Rails.configuration.force_ssl : false), urls: %w[ / ], index_html: true, } end |
.stringify_keys!(hash) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/rails_build.rb', line 81 def Configuration.stringify_keys!(hash) hash.transform_keys!(&:to_s) hash.each do |key, val| if val.is_a?(Hash) Configuration.stringify_keys!(val) end end hash end |
Instance Method Details
#to_json(*args, **kws, &block) ⇒ Object
129 130 131 |
# File 'lib/rails_build.rb', line 129 def to_json(*args, **kws, &block) JSON.pretty_generate(self) end |