Class: Ooor::MiniActiveResource

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Conversion, ActiveModel::Serializers::JSON, ActiveModel::Serializers::Xml
Defined in:
lib/ooor/mini_active_resource.rb

Direct Known Subclasses

Base

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



28
29
30
# File 'lib/ooor/mini_active_resource.rb', line 28

def attributes
  @attributes
end

#idObject

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_nameObject



9
10
11
# File 'lib/ooor/mini_active_resource.rb', line 9

def element_name
  @element_name ||= model_name.element
end

Instance Method Details

#errorsObject

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?

Returns:

  • (Boolean)


38
39
40
# File 'lib/ooor/mini_active_resource.rb', line 38

def new?
  !@persisted
end

#persisted?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/ooor/mini_active_resource.rb', line 43

def persisted?
  @persisted
end

#reloadObject



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(options={})
  super(include_root_in_json ? { :root => self.class.element_name }.merge(options) : options)
end

#to_xml(options = {}) ⇒ Object



34
35
36
# File 'lib/ooor/mini_active_resource.rb', line 34

def to_xml(options={})
  super({ :root => self.class.element_name }.merge(options))
end