Sha256: e37d48c6d3a822a6896ff66125de48c6665ddf0250b1adc98ae7dbb757736c69
Contents?: true
Size: 1.46 KB
Versions: 4
Compression:
Stored size: 1.46 KB
Contents
# Attributes Attributes are read from the Server application's {file:docs/ResourceDefinition.md Resource Definition}. ## Visibility ### Public Can read and write, data is sent to the server if it has changed ### Protected Can read only. Cannot set or mass-assign # Resource definition # { # ... # protected : [ # ['updated_at', 'time'] # ] # ... # } Resource::Person.new(updated_at: Time.now) # => Raises error resource = Resource::Person.new resource.updated_at = Time.now #=> Raises error ### Private Field is not even definted or included in the {file:docs/ResourceDefinition.md Resource Definition}. For more info see {http://path/to/server/docs ApiResourceServer ApiResource Server} ## Typecasting ApiResource supports the following types: 1. Array 1. Boolean 1. Date 1. Float 1. Integer 1. String 1. Time Attributes are given a type in the {file:docs/ResourceDefinition.md Resource Definition}. For more info see {http://path/to/server/docs ApiResourceServer ApiResource Server} ## Dirty Tracking ApiResource::Base includes ActiveModel::Dirty and uses Dirty Tracking to determine which attributes to send to the server on save. Only attributes that have changed are sent to the server. person = Resource::Person.find(1) person.attributes # => { first_name: 'Aaron', last_name: 'Burr', ...} person.last_name = 'Copeland' person.save # PUT /people/1.json { person: { last_name: 'Copeland' } }
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
api_resource-0.6.25 | docs/Attributes.md |
api_resource-0.6.24 | docs/Attributes.md |
api_resource-0.6.23 | docs/Attributes.md |
api_resource-0.6.22 | docs/Attributes.md |