Class: ActsAsTable::ValueProvider::WrappedValue
- Inherits:
-
Object
- Object
- ActsAsTable::ValueProvider::WrappedValue
- Defined in:
- app/models/concerns/acts_as_table/value_provider.rb
Overview
ActsAsTable wrapped value object.
Instance Attribute Summary collapse
-
#base ⇒ ActiveRecord::Base?
readonly
Returns the record for this ActsAsTable wrapped value object.
-
#options ⇒ Hash<Symbol, Object>
readonly
Returns the options for this ActsAsTable wrapped value object.
-
#source_value ⇒ Object?
readonly
Returns the source value of this ActsAsTable wrapped value object.
-
#target_value ⇒ Object?
readonly
Returns the target value of this ActsAsTable wrapped value object.
-
#value_provider ⇒ ActsAsTable::ValueProvider::InstanceMethods
readonly
Returns the ActsAsTable value provider for this ActsAsTable wrapped value object.
Instance Method Summary collapse
-
#changed! ⇒ Boolean
Sets the ':changed' option for this ActsAsTable wrapped value object to 'true'.
-
#changed? ⇒ Boolean
(also: #changed)
Returns 'true' if the value of this ActsAsTable wrapped value object has changed.
-
#default? ⇒ Boolean
(also: #default)
Returns 'true' if the value of this ActsAsTable wrapped value object is the default value for the value provider.
-
#initialize(value_provider, base = nil, source_value = nil, target_value = nil, **options) ⇒ ActsAsTable::ValueProvider::WrappedValue
constructor
Returns a new ActsAsTable wrapped value object.
Constructor Details
#initialize(value_provider, base = nil, source_value = nil, target_value = nil, **options) ⇒ ActsAsTable::ValueProvider::WrappedValue
Returns a new ActsAsTable wrapped value object.
69 70 71 72 73 |
# File 'app/models/concerns/acts_as_table/value_provider.rb', line 69 def initialize(value_provider, base = nil, source_value = nil, target_value = nil, **) .assert_valid_keys(:changed, :default) @value_provider, @base, @source_value, @target_value, @options = value_provider, base, source_value, target_value, .dup end |
Instance Attribute Details
#base ⇒ ActiveRecord::Base? (readonly)
Returns the record for this ActsAsTable wrapped value object.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/models/concerns/acts_as_table/value_provider.rb', line 56 class WrappedValue attr_reader :value_provider, :base, :source_value, :target_value, :options # Returns a new ActsAsTable wrapped value object. # # @param [ActsAsTable::ValueProvider::InstanceMethods] value_provider # @param [ActiveRecord::Base, nil] base # @param [Object, nil] source_value # @param [Object, nil] target_value # @param [Hash<Symbol, Object>] options # @option options [Boolean] :changed # @option options [Boolean] :default # @return [ActsAsTable::ValueProvider::WrappedValue] def initialize(value_provider, base = nil, source_value = nil, target_value = nil, **) .assert_valid_keys(:changed, :default) @value_provider, @base, @source_value, @target_value, @options = value_provider, base, source_value, target_value, .dup end # Sets the ':changed' option for this ActsAsTable wrapped value object to 'true'. # # @return [Boolean] def changed! @options[:changed] = true end # Returns 'true' if the value of this ActsAsTable wrapped value object has changed. Otherwise, returns 'false'. # # @return [Boolean] def changed? !!@options[:changed] end alias_method :changed, :changed? # Returns 'true' if the value of this ActsAsTable wrapped value object is the default value for the value provider. Otherwise, returns 'false'. # # @return [Boolean] def default? !!@options[:default] end alias_method :default, :default? end |
#options ⇒ Hash<Symbol, Object> (readonly)
Returns the options for this ActsAsTable wrapped value object.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/models/concerns/acts_as_table/value_provider.rb', line 56 class WrappedValue attr_reader :value_provider, :base, :source_value, :target_value, :options # Returns a new ActsAsTable wrapped value object. # # @param [ActsAsTable::ValueProvider::InstanceMethods] value_provider # @param [ActiveRecord::Base, nil] base # @param [Object, nil] source_value # @param [Object, nil] target_value # @param [Hash<Symbol, Object>] options # @option options [Boolean] :changed # @option options [Boolean] :default # @return [ActsAsTable::ValueProvider::WrappedValue] def initialize(value_provider, base = nil, source_value = nil, target_value = nil, **) .assert_valid_keys(:changed, :default) @value_provider, @base, @source_value, @target_value, @options = value_provider, base, source_value, target_value, .dup end # Sets the ':changed' option for this ActsAsTable wrapped value object to 'true'. # # @return [Boolean] def changed! @options[:changed] = true end # Returns 'true' if the value of this ActsAsTable wrapped value object has changed. Otherwise, returns 'false'. # # @return [Boolean] def changed? !!@options[:changed] end alias_method :changed, :changed? # Returns 'true' if the value of this ActsAsTable wrapped value object is the default value for the value provider. Otherwise, returns 'false'. # # @return [Boolean] def default? !!@options[:default] end alias_method :default, :default? end |
#source_value ⇒ Object? (readonly)
Returns the source value of this ActsAsTable wrapped value object.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/models/concerns/acts_as_table/value_provider.rb', line 56 class WrappedValue attr_reader :value_provider, :base, :source_value, :target_value, :options # Returns a new ActsAsTable wrapped value object. # # @param [ActsAsTable::ValueProvider::InstanceMethods] value_provider # @param [ActiveRecord::Base, nil] base # @param [Object, nil] source_value # @param [Object, nil] target_value # @param [Hash<Symbol, Object>] options # @option options [Boolean] :changed # @option options [Boolean] :default # @return [ActsAsTable::ValueProvider::WrappedValue] def initialize(value_provider, base = nil, source_value = nil, target_value = nil, **) .assert_valid_keys(:changed, :default) @value_provider, @base, @source_value, @target_value, @options = value_provider, base, source_value, target_value, .dup end # Sets the ':changed' option for this ActsAsTable wrapped value object to 'true'. # # @return [Boolean] def changed! @options[:changed] = true end # Returns 'true' if the value of this ActsAsTable wrapped value object has changed. Otherwise, returns 'false'. # # @return [Boolean] def changed? !!@options[:changed] end alias_method :changed, :changed? # Returns 'true' if the value of this ActsAsTable wrapped value object is the default value for the value provider. Otherwise, returns 'false'. # # @return [Boolean] def default? !!@options[:default] end alias_method :default, :default? end |
#target_value ⇒ Object? (readonly)
Returns the target value of this ActsAsTable wrapped value object.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/models/concerns/acts_as_table/value_provider.rb', line 56 class WrappedValue attr_reader :value_provider, :base, :source_value, :target_value, :options # Returns a new ActsAsTable wrapped value object. # # @param [ActsAsTable::ValueProvider::InstanceMethods] value_provider # @param [ActiveRecord::Base, nil] base # @param [Object, nil] source_value # @param [Object, nil] target_value # @param [Hash<Symbol, Object>] options # @option options [Boolean] :changed # @option options [Boolean] :default # @return [ActsAsTable::ValueProvider::WrappedValue] def initialize(value_provider, base = nil, source_value = nil, target_value = nil, **) .assert_valid_keys(:changed, :default) @value_provider, @base, @source_value, @target_value, @options = value_provider, base, source_value, target_value, .dup end # Sets the ':changed' option for this ActsAsTable wrapped value object to 'true'. # # @return [Boolean] def changed! @options[:changed] = true end # Returns 'true' if the value of this ActsAsTable wrapped value object has changed. Otherwise, returns 'false'. # # @return [Boolean] def changed? !!@options[:changed] end alias_method :changed, :changed? # Returns 'true' if the value of this ActsAsTable wrapped value object is the default value for the value provider. Otherwise, returns 'false'. # # @return [Boolean] def default? !!@options[:default] end alias_method :default, :default? end |
#value_provider ⇒ ActsAsTable::ValueProvider::InstanceMethods (readonly)
Returns the ActsAsTable value provider for this ActsAsTable wrapped value object.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/models/concerns/acts_as_table/value_provider.rb', line 56 class WrappedValue attr_reader :value_provider, :base, :source_value, :target_value, :options # Returns a new ActsAsTable wrapped value object. # # @param [ActsAsTable::ValueProvider::InstanceMethods] value_provider # @param [ActiveRecord::Base, nil] base # @param [Object, nil] source_value # @param [Object, nil] target_value # @param [Hash<Symbol, Object>] options # @option options [Boolean] :changed # @option options [Boolean] :default # @return [ActsAsTable::ValueProvider::WrappedValue] def initialize(value_provider, base = nil, source_value = nil, target_value = nil, **) .assert_valid_keys(:changed, :default) @value_provider, @base, @source_value, @target_value, @options = value_provider, base, source_value, target_value, .dup end # Sets the ':changed' option for this ActsAsTable wrapped value object to 'true'. # # @return [Boolean] def changed! @options[:changed] = true end # Returns 'true' if the value of this ActsAsTable wrapped value object has changed. Otherwise, returns 'false'. # # @return [Boolean] def changed? !!@options[:changed] end alias_method :changed, :changed? # Returns 'true' if the value of this ActsAsTable wrapped value object is the default value for the value provider. Otherwise, returns 'false'. # # @return [Boolean] def default? !!@options[:default] end alias_method :default, :default? end |
Instance Method Details
#changed! ⇒ Boolean
Sets the ':changed' option for this ActsAsTable wrapped value object to 'true'.
78 79 80 |
# File 'app/models/concerns/acts_as_table/value_provider.rb', line 78 def changed! @options[:changed] = true end |
#changed? ⇒ Boolean Also known as: changed
Returns 'true' if the value of this ActsAsTable wrapped value object has changed. Otherwise, returns 'false'.
85 86 87 |
# File 'app/models/concerns/acts_as_table/value_provider.rb', line 85 def changed? !!@options[:changed] end |
#default? ⇒ Boolean Also known as: default
Returns 'true' if the value of this ActsAsTable wrapped value object is the default value for the value provider. Otherwise, returns 'false'.
93 94 95 |
# File 'app/models/concerns/acts_as_table/value_provider.rb', line 93 def default? !!@options[:default] end |