Class: Asdawqw::Policy

Inherits:
BaseModel show all
Defined in:
lib/asdawqw/models/policy.rb

Overview

Policy Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

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_allowedBoolean

Children policy

Returns:

  • (Boolean)


23
24
25
# File 'lib/asdawqw/models/policy.rb', line 23

def children_allowed
  @children_allowed
end

#internet_policyInternetPolicy

Internet policy

Returns:



11
12
13
# File 'lib/asdawqw/models/policy.rb', line 11

def internet_policy
  @internet_policy
end

#parking_policyParkingPolicy

Parking policy

Returns:



15
16
17
# File 'lib/asdawqw/models/policy.rb', line 15

def parking_policy
  @parking_policy
end

#pet_policyPetPolicy

Bed policy

Returns:



19
20
21
# File 'lib/asdawqw/models/policy.rb', line 19

def pet_policy
  @pet_policy
end

#smoking_allowedBoolean

Smoking policy

Returns:

  • (Boolean)


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

.namesObject

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