Class: Miasma::Types::ThinModel
- Inherits:
-
Data
- Object
- Data
- Miasma::Types::ThinModel
- Defined in:
- lib/miasma/types/thin_model.rb
Overview
Base data container
Direct Known Subclasses
Models::AutoScale::Group::Balancer, Models::AutoScale::Group::Server, Models::Compute::Server::Network, Models::LoadBalancer::Balancer::Server
Instance Attribute Summary (collapse)
-
- (Miasma::Types::Api) api
readonly
Service API.
Class Method Summary (collapse)
-
+ (Class) model(klass = nil)
Get/Set fat model.
Instance Method Summary (collapse)
-
- (Miasma::Types::Model) expand
(also: #instance)
Build fat model instance.
-
- (ThinModel) initialize(api, args = {})
constructor
Build new instance.
-
- (Class) model
Associated model class.
- - (FalseClass) persisted?
Constructor Details
- (ThinModel) initialize(api, args = {})
Build new instance
40 41 42 43 |
# File 'lib/miasma/types/thin_model.rb', line 40 def initialize(api, args={}) @api = api super args end |
Instance Attribute Details
- (Miasma::Types::Api) api (readonly)
Returns service API
34 35 36 |
# File 'lib/miasma/types/thin_model.rb', line 34 def api @api end |
Class Method Details
+ (Class) model(klass = nil)
Get/Set fat model
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/miasma/types/thin_model.rb', line 15 def model(klass=nil) if(klass) unless(klass.ancestors.include?(Miasma::Types::Model)) raise TypeError.new "Expecting `Miasma::Types::Model` subclass! (got #{klass})" else self._model = klass end end self._model end |
Instance Method Details
- (Miasma::Types::Model) expand Also known as: instance
Build fat model instance
66 67 68 69 70 |
# File 'lib/miasma/types/thin_model.rb', line 66 def inst = model.new(api) inst.data[:id] = self.id inst.reload end |
- (Class) model
Note:
will deconstruct namespace and rebuild using provider
Associated model class
55 56 57 58 59 60 61 |
# File 'lib/miasma/types/thin_model.rb', line 55 def model if(self.class.model) self.class.model else raise NotImplementedError.new "No associated model for this thin model type (#{self.class})" end end |
- (FalseClass) persisted?
Note:
thin models are always false
47 48 49 |
# File 'lib/miasma/types/thin_model.rb', line 47 def persisted? false end |