nephophobia 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/nephophobia.rb CHANGED
@@ -15,9 +15,13 @@ module Nephophobia
15
15
  class ResponseData
16
16
  attr_reader :return, :request_id
17
17
 
18
- def initialize hash
19
- @request_id = hash["requestId"]
20
- @return = hash["return"] == "true"
18
+ attr_accessor :attributes
19
+
20
+ def initialize attributes
21
+ @attributes = attributes
22
+
23
+ @request_id = attributes["requestId"]
24
+ @return = attributes["return"] == "true"
21
25
  end
22
26
  end
23
27
 
@@ -30,3 +34,28 @@ module Nephophobia
30
34
  (obj.is_a? Hash) ? [obj] : obj
31
35
  end
32
36
  end
37
+
38
+ ##
39
+ # Allow Data Classes to comply with ActiveModel.
40
+
41
+ module Nephophobia
42
+ class Rails
43
+ CLASSES = [
44
+ ::Nephophobia::ComputeData,
45
+ ::Nephophobia::CredentialData,
46
+ ::Nephophobia::ImageData,
47
+ ::Nephophobia::MemberData,
48
+ ::Nephophobia::ProjectData,
49
+ ::Nephophobia::RoleData,
50
+ ::Nephophobia::UserData
51
+ ].freeze
52
+
53
+ def self.insert
54
+ CLASSES.each do |clazz|
55
+ clazz.class_eval do
56
+ include ActiveModel::Serialization
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -4,9 +4,13 @@ module Nephophobia
4
4
  attr_reader :key_name, :launch_time, :name, :owner_id, :placement
5
5
  attr_reader :private_dns_name, :project_id, :public_dns_name, :state
6
6
 
7
- def initialize hash
8
- @project_id = hash['ownerId']
9
- item = hash['instancesSet']['item']
7
+ attr_accessor :attributes
8
+
9
+ def initialize attributes
10
+ @attributes = attributes
11
+
12
+ @project_id = attributes['ownerId']
13
+ item = attributes['instancesSet']['item']
10
14
  item = item.first if item.is_a?(Array)
11
15
  @description = item['displayDescription']
12
16
  @name = item['displayName']
@@ -2,10 +2,14 @@ module Nephophobia
2
2
  class CredentialData
3
3
  attr_reader :fingerprint, :material, :name
4
4
 
5
- def initialize hash
6
- @material = hash['keyMaterial']
7
- @name = hash['keyName']
8
- @fingerprint = hash['keyFingerprint']
5
+ attr_accessor :attributes
6
+
7
+ def initialize attributes
8
+ @attributes = attributes
9
+
10
+ @material = attributes['keyMaterial']
11
+ @name = attributes['keyName']
12
+ @fingerprint = attributes['keyFingerprint']
9
13
  end
10
14
  end
11
15
 
@@ -3,16 +3,20 @@ module Nephophobia
3
3
  attr_reader :architecture, :image_id, :image_location, :image_owner_id
4
4
  attr_reader :image_type, :kernel_id, :is_public, :state
5
5
 
6
- def initialize hash
7
- @architecture = hash['architecture']
8
- @id = hash['id']
9
- @image_id = hash['imageId']
10
- @image_location = hash['imageLocation']
11
- @image_owner_id = hash['imageOwnerId']
12
- @image_type = hash['imageType']
13
- @is_public = hash['isPublic']
14
- @kernel_id = hash['kernelId']
15
- @state = hash['imageState']
6
+ attr_accessor :attributes
7
+
8
+ def initialize attributes
9
+ @attributes = attributes
10
+
11
+ @architecture = attributes['architecture']
12
+ @id = attributes['id']
13
+ @image_id = attributes['imageId']
14
+ @image_location = attributes['imageLocation']
15
+ @image_owner_id = attributes['imageOwnerId']
16
+ @image_type = attributes['imageType']
17
+ @is_public = attributes['isPublic']
18
+ @kernel_id = attributes['kernelId']
19
+ @state = attributes['imageState']
16
20
  end
17
21
  end
18
22
 
@@ -2,19 +2,27 @@ module Nephophobia
2
2
  class ProjectData
3
3
  attr_reader :name, :manager_id, :description
4
4
 
5
- def initialize hash
6
- @name = hash['projectname']
7
- @manager_id = hash['projectManagerId']
8
- @description = hash['description']
9
- @member = hash['member']
5
+ attr_accessor :attributes
6
+
7
+ def initialize attributes
8
+ @attributes = attributes
9
+
10
+ @name = attributes['projectname']
11
+ @manager_id = attributes['projectManagerId']
12
+ @description = attributes['description']
13
+ @member = attributes['member']
10
14
  end
11
15
  end
12
16
 
13
17
  class MemberData
14
18
  attr_reader :member
15
19
 
16
- def initialize hash
17
- @member = hash['member']
20
+ attr_accessor :attributes
21
+
22
+ def initialize attributes
23
+ @attributes = attributes
24
+
25
+ @member = attributes['member']
18
26
  end
19
27
  end
20
28
 
@@ -2,8 +2,12 @@ module Nephophobia
2
2
  class RoleData
3
3
  attr_reader :name
4
4
 
5
- def initialize hash
6
- @name = hash['role']
5
+ attr_accessor :attributes
6
+
7
+ def initialize attributes
8
+ @attributes = attributes
9
+
10
+ @name = attributes['role']
7
11
  end
8
12
  end
9
13
 
@@ -2,10 +2,14 @@ module Nephophobia
2
2
  class UserData
3
3
  attr_reader :accesskey, :username, :secretkey
4
4
 
5
- def initialize hash
6
- @accesskey = hash['accesskey']
7
- @username = hash['username']
8
- @secretkey = hash['secretkey']
5
+ attr_accessor :attributes
6
+
7
+ def initialize attributes
8
+ @attributes = attributes
9
+
10
+ @accesskey = attributes['accesskey']
11
+ @username = attributes['username']
12
+ @secretkey = attributes['secretkey']
9
13
  end
10
14
  end
11
15
 
@@ -1,3 +1,3 @@
1
1
  module Nephophobia
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: nephophobia
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - John Dewey
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-04-20 00:00:00 -07:00
14
+ date: 2011-04-21 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency