Class: Asdawqw::Policy
- Defined in:
- lib/asdawqw/models/policy.rb
Overview
Policy Model.
Instance Attribute Summary collapse
-
#children_allowed ⇒ Boolean
Children policy.
-
#internet_policy ⇒ InternetPolicy
Internet policy.
-
#parking_policy ⇒ ParkingPolicy
Parking policy.
-
#pet_policy ⇒ PetPolicy
Bed policy.
-
#smoking_allowed ⇒ Boolean
Smoking policy.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(children_allowed = nil, smoking_allowed = nil, internet_policy = nil, parking_policy = nil, pet_policy = nil) ⇒ Policy
constructor
A new instance of Policy.
Methods inherited from BaseModel
Constructor Details
#initialize(children_allowed = nil, smoking_allowed = nil, internet_policy = nil, parking_policy = nil, pet_policy = nil) ⇒ Policy
Returns a new instance of Policy.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/asdawqw/models/policy.rb', line 40 def initialize(children_allowed = nil, smoking_allowed = nil, internet_policy = nil, parking_policy = nil, pet_policy = nil) @internet_policy = internet_policy @parking_policy = parking_policy @pet_policy = pet_policy @children_allowed = children_allowed @smoking_allowed = smoking_allowed end |
Instance Attribute Details
#children_allowed ⇒ Boolean
Children policy
23 24 25 |
# File 'lib/asdawqw/models/policy.rb', line 23 def children_allowed @children_allowed end |
#internet_policy ⇒ InternetPolicy
Internet policy
11 12 13 |
# File 'lib/asdawqw/models/policy.rb', line 11 def internet_policy @internet_policy end |
#parking_policy ⇒ ParkingPolicy
Parking policy
15 16 17 |
# File 'lib/asdawqw/models/policy.rb', line 15 def parking_policy @parking_policy end |
#pet_policy ⇒ PetPolicy
Bed policy
19 20 21 |
# File 'lib/asdawqw/models/policy.rb', line 19 def pet_policy @pet_policy end |
#smoking_allowed ⇒ Boolean
Smoking policy
27 28 29 |
# File 'lib/asdawqw/models/policy.rb', line 27 def smoking_allowed @smoking_allowed end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/asdawqw/models/policy.rb', line 53 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. children_allowed = hash['childrenAllowed'] smoking_allowed = hash['smokingAllowed'] internet_policy = InternetPolicy.from_hash(hash['internetPolicy']) if hash['internetPolicy'] parking_policy = ParkingPolicy.from_hash(hash['parkingPolicy']) if hash['parkingPolicy'] pet_policy = PetPolicy.from_hash(hash['petPolicy']) if hash['petPolicy'] # Create object from extracted values. Policy.new(children_allowed, smoking_allowed, internet_policy, parking_policy, pet_policy) end |
.names ⇒ Object
A mapping from model property names to API property names.
30 31 32 33 34 35 36 37 38 |
# File 'lib/asdawqw/models/policy.rb', line 30 def self.names @_hash = {} if @_hash.nil? @_hash['internet_policy'] = 'internetPolicy' @_hash['parking_policy'] = 'parkingPolicy' @_hash['pet_policy'] = 'petPolicy' @_hash['children_allowed'] = 'childrenAllowed' @_hash['smoking_allowed'] = 'smokingAllowed' @_hash end |