Class: RubyHome::CharacteristicFactory
- Inherits:
-
Object
- Object
- RubyHome::CharacteristicFactory
- Defined in:
- lib/ruby_home/factories/characteristic_factory.rb
Constant Summary collapse
- DEFAULT_VALUES =
{ identify: nil, }.freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.create(characteristic_name, service:, subtype: 'default', value: nil) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/ruby_home/factories/characteristic_factory.rb', line 7 def self.create(characteristic_name, service: , subtype: 'default' , value: nil) new( characteristic_name: characteristic_name, service: service, subtype: subtype, value: value ).create end |
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ruby_home/factories/characteristic_factory.rb', line 16 def create characteristic = Characteristic.new( description: template.description, format: template.format, name: characteristic_name, properties: template.properties, service: service, unit: template.unit, uuid: template.uuid, value: value ) if persisted_characteristic characteristic.instance_id = persisted_characteristic.instance_id else characteristic.instance_id = accessory.next_available_instance_id persist_characteristic(characteristic) end service.characteristics << characteristic characteristic end |