class Particle::Platform
Domain model for one Particle
Platform
from the /v1/build_targets endpoint
Constants
- IDS
Public Class Methods
id_for_name(name)
click to toggle source
# File lib/particle/platform.rb, line 27 def self.id_for_name(name) IDS.invert[name] end
name_for_id(id)
click to toggle source
# File lib/particle/platform.rb, line 31 def self.name_for_id(id) IDS[id] end
new(client, attributes)
click to toggle source
Calls superclass method
Particle::Model::new
# File lib/particle/platform.rb, line 13 def initialize(client, attributes) if attributes.is_a? String name = attributes attributes = { id: self.class.id_for_name(name), name: name } end if attributes.is_a? Integer id = attributes attributes = { id: id, name: self.class.name_for_id(id) } end super(client, attributes) end
Public Instance Methods
name()
click to toggle source
This avoids upstream magic from making .name a Symbol–keep it a string yo
# File lib/particle/platform.rb, line 38 def name @attributes[:name].to_s end