Class: RubyHome::ServiceFactory
- Inherits:
-
Object
- Object
- RubyHome::ServiceFactory
- Defined in:
- lib/ruby_home/factories/service_factory.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.create(service_name, accessory: Accessory.new, subtype: 'default', **options) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/ruby_home/factories/service_factory.rb', line 3 def self.create(service_name, accessory: Accessory.new, subtype: 'default', **) new( service_name: service_name, accessory: accessory, subtype: subtype, ** ).create end |
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ruby_home/factories/service_factory.rb', line 12 def create service = Service.new( accessory: accessory, description: template.description, name: service_name, uuid: template.uuid, ) if persisted_service service.instance_id = persisted_service.instance_id else service.instance_id = accessory.next_available_instance_id persist_service(service) end accessory.services << service create_required_characteristics(service) create_optional_characteristics(service) unless accessory_information_factory? create_accessory_information end service end |