Module: RailsReadonlyInjector
- Defined in:
- lib/rails_readonly_injector.rb,
lib/rails_readonly_injector/version.rb,
lib/rails_readonly_injector/configuration.rb
Constant Summary collapse
- VERSION =
'1.2.0'
Class Method Summary collapse
-
.config {|configuration| ... } ⇒ Configuration
Sets the desired configuration object, if a block is provided, and then returns the current configuration object.
-
.in_read_only_mode? ⇒ Boolean
Returns the currently loaded ‘config.read_only` value.
-
.reload! ⇒ Object
Applies changes defined in the ‘config` object and resets `config.dirty?` to false.
Class Method Details
.config {|configuration| ... } ⇒ Configuration
Sets the desired configuration object, if a block is provided, and then returns the current configuration object.
44 45 46 47 48 |
# File 'lib/rails_readonly_injector.rb', line 44 def self.config yield configuration if block_given? configuration end |
.in_read_only_mode? ⇒ Boolean
Returns the currently loaded ‘config.read_only` value.
32 33 34 35 36 37 38 39 |
# File 'lib/rails_readonly_injector.rb', line 32 def self.in_read_only_mode? if config.dirty? && config.changed_attributes.key?(:read_only) # Return the previously stored value config.changed_attributes[:read_only] else config.send(:read_only) end end |
.reload! ⇒ Object
Applies changes defined in the ‘config` object and resets `config.dirty?` to false
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rails_readonly_injector.rb', line 9 def self.reload! config.classes_to_include.each do |klass| # Ensure we restore classes that we want to exclude, to their defaults # in case they were previously marked as read-only. if config.classes_to_exclude.include? klass restore_readonly_method(klass) next end if config.send(:read_only) override_readonly_method(klass) else restore_readonly_method(klass) end end inject_error_handler_into_actioncontroller_base config.send(:reset_dirty_status!) end |