Class: Company::Resource
- Inherits:
-
Object
- Object
- Company::Resource
- Defined in:
- lib/company/resource.rb
Overview
What every record shares: the node the platform answered it as. Built by the gem that read it, never by a caller.
Direct Known Subclasses
Business, Customer, Job, Lead, Line, Location, Quote, Technician, Visit, Window
Class Method Summary collapse
-
.keys ⇒ Hash
The node keys the platform spells otherwise than the vocabulary, by the reader they answer:
{ phone: :phone_number }reads Business#phone offphone_number. -
.node_keys ⇒ Array<Symbol>
The keys a platform is expected to answer a node with: each attribute the kind reads, through Resource.keys, so a gem asks its platform for exactly these and writes none by hand.
Instance Method Summary collapse
-
#id ⇒ String
ID the platform files the record under.
-
#initialize(node: {}) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
#initialize(node: {}) ⇒ Resource
Returns a new instance of Resource.
17 18 19 |
# File 'lib/company/resource.rb', line 17 def initialize(node: {}) @node = node.with_indifferent_access end |
Class Method Details
.keys ⇒ Hash
The node keys the platform spells otherwise than the vocabulary, by the reader they
answer: { phone: :phone_number } reads Business#phone off phone_number. A gem
declares its own; a reader left out reads the key of its own name.
9 |
# File 'lib/company/resource.rb', line 9 def self.keys = {} |
.node_keys ⇒ Array<Symbol>
The keys a platform is expected to answer a node with: each attribute the kind reads, through keys, so a gem asks its platform for exactly these and writes none by hand.
14 |
# File 'lib/company/resource.rb', line 14 def self.node_keys = attributes.map { |name| keys.fetch name, name } |
Instance Method Details
#id ⇒ String
Returns ID the platform files the record under.
22 |
# File 'lib/company/resource.rb', line 22 def id = attribute :id |