Class: Rails::Angulate::Mappers::BaseMapper
- Inherits:
-
Object
- Object
- Rails::Angulate::Mappers::BaseMapper
- Defined in:
- lib/rails/angulate/mappers/base_mapper.rb
Direct Known Subclasses
FormatValidatorMapper, LengthValidatorMapper, NumericalityValidatorMapper, ValidatorMapper
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#validator ⇒ Object
readonly
Returns the value of attribute validator.
Class Method Summary collapse
Instance Method Summary collapse
- #error_messages ⇒ Object
- #full_message(message) ⇒ Object
-
#initialize(model, attribute, validator) ⇒ BaseMapper
constructor
A new instance of BaseMapper.
Constructor Details
#initialize(model, attribute, validator) ⇒ BaseMapper
Returns a new instance of BaseMapper.
13 14 15 16 17 |
# File 'lib/rails/angulate/mappers/base_mapper.rb', line 13 def initialize(model, attribute, validator) @model = model @attribute = attribute @validator = validator end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
5 6 7 |
# File 'lib/rails/angulate/mappers/base_mapper.rb', line 5 def attribute @attribute end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/rails/angulate/mappers/base_mapper.rb', line 5 def model @model end |
#validator ⇒ Object (readonly)
Returns the value of attribute validator.
5 6 7 |
# File 'lib/rails/angulate/mappers/base_mapper.rb', line 5 def validator @validator end |
Class Method Details
.inherited(mapper) ⇒ Object
7 8 9 |
# File 'lib/rails/angulate/mappers/base_mapper.rb', line 7 def self.inherited(mapper) Mappers.register_mapper(mapper) end |
Instance Method Details
#error_messages ⇒ Object
19 20 21 |
# File 'lib/rails/angulate/mappers/base_mapper.rb', line 19 def [] end |
#full_message(message) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rails/angulate/mappers/base_mapper.rb', line 23 def () return if attribute == :base attr_name = attribute.to_s.tr('.', '_').humanize attr_name = @model.class.human_attribute_name(attribute, default: attribute.to_s.humanize) with_i18n do |locale| locale.t(:format, { default: "%{attribute} %{message}", attribute: attr_name.to_s.humanize, message: }) end end |