Class: ActiveModel::Error

Inherits:
Object show all
Defined in:
lib/reactive_record/active_record/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msgs = {}) ⇒ Error

Returns a new instance of Error.



7
8
9
10
# File 'lib/reactive_record/active_record/error.rb', line 7

def initialize(msgs = {})
  @messages = msgs || {}
  @messages.each { |attribute, messages| @messages[attribute] = messages.uniq }
end

Instance Attribute Details

#messagesObject (readonly)

Returns the value of attribute messages.



5
6
7
# File 'lib/reactive_record/active_record/error.rb', line 5

def messages
  @messages
end

Instance Method Details

#[](attribute) ⇒ Object



12
13
14
# File 'lib/reactive_record/active_record/error.rb', line 12

def [](attribute)
  messages[attribute]
end

#delete(attribute) ⇒ Object



16
17
18
# File 'lib/reactive_record/active_record/error.rb', line 16

def delete(attribute)
  messages.delete(attribute)
end

#empty?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/reactive_record/active_record/error.rb', line 20

def empty?
  messages.empty?
end