Class: CassandraORM::Model::Errors
- Inherits:
-
Object
- Object
- CassandraORM::Model::Errors
- Defined in:
- lib/cassandra-orm/model/errors.rb
Instance Method Summary collapse
- #append(attr, key, options = {}) ⇒ Object
- #full_messages(locale: :en) ⇒ Object
-
#initialize(object) ⇒ Errors
constructor
A new instance of Errors.
Constructor Details
#initialize(object) ⇒ Errors
10 11 12 13 |
# File 'lib/cassandra-orm/model/errors.rb', line 10 def initialize object @object = object @errors = Hash.new { |h, k| h[k] = {} } end |
Instance Method Details
#append(attr, key, options = {}) ⇒ Object
17 18 19 |
# File 'lib/cassandra-orm/model/errors.rb', line 17 def append attr, key, = {} @errors[attr].merge! key => end |
#full_messages(locale: :en) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cassandra-orm/model/errors.rb', line 21 def locale: :en @errors.map do |attr, errlist| errlist.map do |key, | if attr.to_s =~ /\[(.+)\]/ skey, name = $1, @object.class.name.underscore I18n.t key, .merge(scope: [:cassandra, name, :errors, skey], locale: locale) else I18n.t key, .merge(attr: attr, scope: [:cassandra, :errors], locale: locale) end end end.flatten end |