bahtera 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,12 +10,24 @@ module Bahtera
10
10
  attributes = hash_response.keys
11
11
  self.class.class_eval { attr_reader *attributes }
12
12
  attributes.each do |attr_name|
13
- if hash_response[attr_name]
14
- instance_variable_set("@#{attr_name}",
15
- hash_response[attr_name])
13
+ attribute_value = hash_response[attr_name]
14
+ if attribute_value
15
+ if attribute_value.is_a?(Array)
16
+ assign_array_attributes(attr_name, attribute_value)
17
+ else
18
+ instance_variable_set("@#{attr_name}", attribute_value)
19
+ end
16
20
  end
17
21
  end
18
22
  end
23
+
24
+ def assign_array_attributes(attr_name, hash_array)
25
+ value = hash_array.map { |hash_attr| BaseKata.new(hash_attr) }
26
+ instance_variable_set("@#{attr_name}", value)
27
+ self.class.send :define_method, "has_#{attr_name}?" do
28
+ send(attr_name).any?
29
+ end
30
+ end
19
31
  end
20
32
 
21
33
  class Kata < BaseKata
@@ -27,12 +39,6 @@ module Bahtera
27
39
  private
28
40
  def assign_attribute_names(hash_response)
29
41
  super hash_response
30
- %w( root definition reference proverbs translations all_relation ).each do |attribute_name|
31
- override_array_hash(attribute_name)
32
- self.class.send :define_method, "has_#{attribute_name}?" do
33
- send(attribute_name).any?
34
- end
35
- end
36
42
  assign_relations if relation.any?
37
43
  end
38
44
 
@@ -54,12 +60,5 @@ module Bahtera
54
60
  end
55
61
  end
56
62
  end
57
-
58
- def override_array_hash(attr_name)
59
- new_value = send(attr_name).map do |hash_attr|
60
- BaseKata.new(hash_attr)
61
- end
62
- instance_variable_set("@#{attr_name}", new_value)
63
- end
64
63
  end
65
64
  end
@@ -1,3 +1,3 @@
1
1
  module Bahtera
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bahtera
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-22 00:00:00.000000000 Z
12
+ date: 2013-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -114,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  segments:
116
116
  - 0
117
- hash: -3553642502716914400
117
+ hash: -627252859727441228
118
118
  required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  none: false
120
120
  requirements:
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  segments:
125
125
  - 0
126
- hash: -3553642502716914400
126
+ hash: -627252859727441228
127
127
  requirements: []
128
128
  rubyforge_project:
129
129
  rubygems_version: 1.8.25