Class: ActsAsTable::Value
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActsAsTable::Value
- Defined in:
- app/models/acts_as_table/value.rb
Overview
ActsAsTable value.
Instance Attribute Summary collapse
-
#position ⇒ Integer?
Returns the position of this ActsAsTable value or
nil
. -
#record_errors_count ⇒ Integer
readonly
Returns the number of ActsAsTable record errors for this ActsAsTable value.
- #record_id ⇒ Object readonly
-
#source_value ⇒ String?
Returns the source value for this ActsAsTable value.
-
#target_value ⇒ String?
Returns the target value for this ActsAsTable value.
-
#value_provider_changed ⇒ Boolean
Returns
true
if the ActsAsTable value provider changed the value for this ActsAsTable value.
Belongs to collapse
-
#column_model ⇒ ActsAsTable::ColumnModel?
Returns the ActsAsTable column model that provided this ActsAsTable value or
nil
. -
#record ⇒ ActsAsTable::Record
Returns the ActsAsTable record for this ActsAsTable value.
-
#value_provider ⇒ ActsAsTable::ValueProvider::InstanceMethods
Returns the ActsAsTable value provider that provider the value for this ActsAsTable value.
Has many collapse
-
#record_errors ⇒ ActiveRecord::Relation<ActsAsTable::RecordError>
Returns the ActsAsTable record errors for this ActsAsTable value.
Instance Attribute Details
#position ⇒ Integer?
Returns the position of this ActsAsTable value or nil
.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/acts_as_table/value.rb', line 24 class Value < ::ActiveRecord::Base # @!parse # include ActsAsTable::ValueProvider # include ActsAsTable::ValueProviderAssociationMethods self.table_name = ActsAsTable.values_table # Returns the ActsAsTable column model that provided this ActsAsTable value or `nil`. # # @return [ActsAsTable::ColumnModel, nil] belongs_to :column_model, **{ class_name: 'ActsAsTable::ColumnModel', inverse_of: :values, required: false, } # Returns the ActsAsTable record for this ActsAsTable value. belongs_to :record, **{ class_name: 'ActsAsTable::Record', counter_cache: 'values_count', inverse_of: :values, required: true, } # Returns the ActsAsTable value provider that provider the value for this ActsAsTable value. # # @return [ActsAsTable::ValueProvider::InstanceMethods] belongs_to :value_provider, **{ polymorphic: true, required: true, } # Returns the ActsAsTable record errors for this ActsAsTable value. has_many :record_errors, -> { order(attribute_name: :asc, message: :asc) }, **{ autosave: false, class_name: 'ActsAsTable::RecordError', dependent: :nullify, foreign_key: 'value_id', inverse_of: :value, validate: false, } validates :record_id, **{ uniqueness: { scope: ['value_provider_id', 'value_provider_type'], }, } # validates :position, **{} # validates :source_value, **{} # validates :target_value, **{} # validates :value_provider_changed, **{} end |
#record_errors_count ⇒ Integer (readonly)
Returns the number of ActsAsTable record errors for this ActsAsTable value.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/acts_as_table/value.rb', line 24 class Value < ::ActiveRecord::Base # @!parse # include ActsAsTable::ValueProvider # include ActsAsTable::ValueProviderAssociationMethods self.table_name = ActsAsTable.values_table # Returns the ActsAsTable column model that provided this ActsAsTable value or `nil`. # # @return [ActsAsTable::ColumnModel, nil] belongs_to :column_model, **{ class_name: 'ActsAsTable::ColumnModel', inverse_of: :values, required: false, } # Returns the ActsAsTable record for this ActsAsTable value. belongs_to :record, **{ class_name: 'ActsAsTable::Record', counter_cache: 'values_count', inverse_of: :values, required: true, } # Returns the ActsAsTable value provider that provider the value for this ActsAsTable value. # # @return [ActsAsTable::ValueProvider::InstanceMethods] belongs_to :value_provider, **{ polymorphic: true, required: true, } # Returns the ActsAsTable record errors for this ActsAsTable value. has_many :record_errors, -> { order(attribute_name: :asc, message: :asc) }, **{ autosave: false, class_name: 'ActsAsTable::RecordError', dependent: :nullify, foreign_key: 'value_id', inverse_of: :value, validate: false, } validates :record_id, **{ uniqueness: { scope: ['value_provider_id', 'value_provider_type'], }, } # validates :position, **{} # validates :source_value, **{} # validates :target_value, **{} # validates :value_provider_changed, **{} end |
#record_id ⇒ Object (readonly)
66 67 68 69 70 |
# File 'app/models/acts_as_table/value.rb', line 66 validates :record_id, **{ uniqueness: { scope: ['value_provider_id', 'value_provider_type'], }, } |
#source_value ⇒ String?
Returns the source value for this ActsAsTable value.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/acts_as_table/value.rb', line 24 class Value < ::ActiveRecord::Base # @!parse # include ActsAsTable::ValueProvider # include ActsAsTable::ValueProviderAssociationMethods self.table_name = ActsAsTable.values_table # Returns the ActsAsTable column model that provided this ActsAsTable value or `nil`. # # @return [ActsAsTable::ColumnModel, nil] belongs_to :column_model, **{ class_name: 'ActsAsTable::ColumnModel', inverse_of: :values, required: false, } # Returns the ActsAsTable record for this ActsAsTable value. belongs_to :record, **{ class_name: 'ActsAsTable::Record', counter_cache: 'values_count', inverse_of: :values, required: true, } # Returns the ActsAsTable value provider that provider the value for this ActsAsTable value. # # @return [ActsAsTable::ValueProvider::InstanceMethods] belongs_to :value_provider, **{ polymorphic: true, required: true, } # Returns the ActsAsTable record errors for this ActsAsTable value. has_many :record_errors, -> { order(attribute_name: :asc, message: :asc) }, **{ autosave: false, class_name: 'ActsAsTable::RecordError', dependent: :nullify, foreign_key: 'value_id', inverse_of: :value, validate: false, } validates :record_id, **{ uniqueness: { scope: ['value_provider_id', 'value_provider_type'], }, } # validates :position, **{} # validates :source_value, **{} # validates :target_value, **{} # validates :value_provider_changed, **{} end |
#target_value ⇒ String?
Returns the target value for this ActsAsTable value.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/acts_as_table/value.rb', line 24 class Value < ::ActiveRecord::Base # @!parse # include ActsAsTable::ValueProvider # include ActsAsTable::ValueProviderAssociationMethods self.table_name = ActsAsTable.values_table # Returns the ActsAsTable column model that provided this ActsAsTable value or `nil`. # # @return [ActsAsTable::ColumnModel, nil] belongs_to :column_model, **{ class_name: 'ActsAsTable::ColumnModel', inverse_of: :values, required: false, } # Returns the ActsAsTable record for this ActsAsTable value. belongs_to :record, **{ class_name: 'ActsAsTable::Record', counter_cache: 'values_count', inverse_of: :values, required: true, } # Returns the ActsAsTable value provider that provider the value for this ActsAsTable value. # # @return [ActsAsTable::ValueProvider::InstanceMethods] belongs_to :value_provider, **{ polymorphic: true, required: true, } # Returns the ActsAsTable record errors for this ActsAsTable value. has_many :record_errors, -> { order(attribute_name: :asc, message: :asc) }, **{ autosave: false, class_name: 'ActsAsTable::RecordError', dependent: :nullify, foreign_key: 'value_id', inverse_of: :value, validate: false, } validates :record_id, **{ uniqueness: { scope: ['value_provider_id', 'value_provider_type'], }, } # validates :position, **{} # validates :source_value, **{} # validates :target_value, **{} # validates :value_provider_changed, **{} end |
#value_provider_changed ⇒ Boolean
Returns true
if the ActsAsTable value provider changed the value for this ActsAsTable value. Otherwise, returns false
.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/acts_as_table/value.rb', line 24 class Value < ::ActiveRecord::Base # @!parse # include ActsAsTable::ValueProvider # include ActsAsTable::ValueProviderAssociationMethods self.table_name = ActsAsTable.values_table # Returns the ActsAsTable column model that provided this ActsAsTable value or `nil`. # # @return [ActsAsTable::ColumnModel, nil] belongs_to :column_model, **{ class_name: 'ActsAsTable::ColumnModel', inverse_of: :values, required: false, } # Returns the ActsAsTable record for this ActsAsTable value. belongs_to :record, **{ class_name: 'ActsAsTable::Record', counter_cache: 'values_count', inverse_of: :values, required: true, } # Returns the ActsAsTable value provider that provider the value for this ActsAsTable value. # # @return [ActsAsTable::ValueProvider::InstanceMethods] belongs_to :value_provider, **{ polymorphic: true, required: true, } # Returns the ActsAsTable record errors for this ActsAsTable value. has_many :record_errors, -> { order(attribute_name: :asc, message: :asc) }, **{ autosave: false, class_name: 'ActsAsTable::RecordError', dependent: :nullify, foreign_key: 'value_id', inverse_of: :value, validate: false, } validates :record_id, **{ uniqueness: { scope: ['value_provider_id', 'value_provider_type'], }, } # validates :position, **{} # validates :source_value, **{} # validates :target_value, **{} # validates :value_provider_changed, **{} end |
Instance Method Details
#column_model ⇒ ActsAsTable::ColumnModel?
Returns the ActsAsTable column model that provided this ActsAsTable value or nil
.
34 35 36 37 38 |
# File 'app/models/acts_as_table/value.rb', line 34 belongs_to :column_model, **{ class_name: 'ActsAsTable::ColumnModel', inverse_of: :values, required: false, } |
#record ⇒ ActsAsTable::Record
Returns the ActsAsTable record for this ActsAsTable value.
41 42 43 44 45 46 |
# File 'app/models/acts_as_table/value.rb', line 41 belongs_to :record, **{ class_name: 'ActsAsTable::Record', counter_cache: 'values_count', inverse_of: :values, required: true, } |
#record_errors ⇒ ActiveRecord::Relation<ActsAsTable::RecordError>
Returns the ActsAsTable record errors for this ActsAsTable value.
57 58 59 60 61 62 63 64 |
# File 'app/models/acts_as_table/value.rb', line 57 has_many :record_errors, -> { order(attribute_name: :asc, message: :asc) }, **{ autosave: false, class_name: 'ActsAsTable::RecordError', dependent: :nullify, foreign_key: 'value_id', inverse_of: :value, validate: false, } |
#value_provider ⇒ ActsAsTable::ValueProvider::InstanceMethods
Returns the ActsAsTable value provider that provider the value for this ActsAsTable value.
51 52 53 54 |
# File 'app/models/acts_as_table/value.rb', line 51 belongs_to :value_provider, **{ polymorphic: true, required: true, } |