Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract device-specific code into a Device module, rename NestThermostat namespace to just Nest #26

Open
stevenpetryk opened this issue Dec 18, 2014 · 1 comment

Comments

@stevenpetryk
Copy link
Collaborator

The new hierarchy should be:

module Nest
  # Handles authorization and API logic
  class Nest; end

  # Stores structures
  class Structure; end

  # Device mixin
  module Device; end

  class Thermostat; include Device; end
end

Using Device as a module seems more appropriate, since Device is technically an abstract class.

Calls could look something like this:

nest = Nest::Nest.new(email: 'email', password: 'password')
nest.structures # => [Structure, Structure]
nest.structures.first.thermostats # => [Thermostat, Thermostat, Thermostat, ...]

# Not certain whether there should be a way to shallowly access the thermostats too
nest.thermostats # => ALL thermostats
@stevenpetryk
Copy link
Collaborator Author

Trying to actually write this, I decided it'd be best to make Device its own class.

module Nest
  class Nest; end
  class Structure; end
  class Device; end
  class Thermostat < Device; end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant