Class: Apiwork::Adapter::Standard::Capability::Writing::Operation::IssueMapper
- Inherits:
-
Object
- Object
- Apiwork::Adapter::Standard::Capability::Writing::Operation::IssueMapper
- Defined in:
- lib/apiwork/adapter/standard/capability/writing/operation/issue_mapper.rb
Constant Summary collapse
- CODE_MAP =
{ accepted: :accepted, blank: :required, confirmation: :confirmed, empty: :required, equal_to: :eq, even: :even, exclusion: :not_in, greater_than: :gt, greater_than_or_equal_to: :gte, in: :in, inclusion: :in, invalid: :invalid, less_than: :lt, less_than_or_equal_to: :lte, not_a_number: :number, not_an_integer: :integer, odd: :odd, other_than: :ne, present: :forbidden, restrict_dependent_destroy: :associated, taken: :unique, too_long: :max, too_short: :min, wrong_length: :length, }.freeze
- DETAIL_MAP =
{ accepted: 'Must be accepted', associated: 'Invalid', confirmed: 'Does not match', eq: 'Wrong value', even: 'Must be even', forbidden: 'Must be blank', format: 'Invalid format', gt: 'Too small', gte: 'Too small', in: 'Invalid value', integer: 'Not an integer', invalid: 'Invalid', length: 'Wrong length', lt: 'Too large', lte: 'Too large', max: 'Too long', min: 'Too short', ne: 'Reserved value', not_in: 'Reserved value', number: 'Not a number', odd: 'Must be odd', required: 'Required', unique: 'Already taken', }.freeze
- META_CODES =
%i[min max length gt gte lt lte eq ne in].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(record, root_path, translator) ⇒ IssueMapper
constructor
A new instance of IssueMapper.
- #map ⇒ Object
Constructor Details
#initialize(record, root_path, translator) ⇒ IssueMapper
Returns a new instance of IssueMapper.
71 72 73 74 75 |
# File 'lib/apiwork/adapter/standard/capability/writing/operation/issue_mapper.rb', line 71 def initialize(record, root_path, translator) @record = record @root_path = Array(root_path) @translator = translator end |
Class Method Details
.map(record, translator, root_path: []) ⇒ Object
66 67 68 |
# File 'lib/apiwork/adapter/standard/capability/writing/operation/issue_mapper.rb', line 66 def map(record, translator, root_path: []) new(record, root_path, translator).map end |
Instance Method Details
#map ⇒ Object
77 78 79 80 81 82 |
# File 'lib/apiwork/adapter/standard/capability/writing/operation/issue_mapper.rb', line 77 def map return [] unless @record.respond_to?(:errors) return [] unless @record.errors.any? attribute_issues + association_issues end |