Class: Ooor::MiniActiveResource
- Inherits:
-
Object
- Object
- Ooor::MiniActiveResource
- Includes:
- ActiveModel::Conversion, ActiveModel::Serializers::JSON, ActiveModel::Serializers::Xml
- Defined in:
- lib/ooor/mini_active_resource.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#id ⇒ Object
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
-
#errors ⇒ Object
Returns the Errors object that holds all information about attribute error messages.
- #new? ⇒ Boolean (also: #new_record?)
- #persisted? ⇒ Boolean
- #reload ⇒ Object
- #to_json(options = {}) ⇒ Object
- #to_xml(options = {}) ⇒ Object
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
28 29 30 |
# File 'lib/ooor/mini_active_resource.rb', line 28 def attributes @attributes end |
#id ⇒ Object
Returns the value of attribute id.
28 29 30 |
# File 'lib/ooor/mini_active_resource.rb', line 28 def id @id end |
Class Method Details
.element_name ⇒ Object
9 10 11 |
# File 'lib/ooor/mini_active_resource.rb', line 9 def element_name @element_name ||= model_name.element end |
Instance Method Details
#errors ⇒ Object
Returns the Errors object that holds all information about attribute error messages.
61 62 63 |
# File 'lib/ooor/mini_active_resource.rb', line 61 def errors @errors ||= ActiveModel::Errors.new(self) end |
#new? ⇒ Boolean Also known as: new_record?
38 39 40 |
# File 'lib/ooor/mini_active_resource.rb', line 38 def new? !@persisted end |
#persisted? ⇒ Boolean
43 44 45 |
# File 'lib/ooor/mini_active_resource.rb', line 43 def persisted? @persisted end |
#reload ⇒ Object
56 57 58 |
# File 'lib/ooor/mini_active_resource.rb', line 56 def reload self.class.find(id) end |
#to_json(options = {}) ⇒ Object
30 31 32 |
# File 'lib/ooor/mini_active_resource.rb', line 30 def to_json(={}) super(include_root_in_json ? { :root => self.class.element_name }.merge() : ) end |
#to_xml(options = {}) ⇒ Object
34 35 36 |
# File 'lib/ooor/mini_active_resource.rb', line 34 def to_xml(={}) super({ :root => self.class.element_name }.merge()) end |