activefacts-api 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a80ac6cfb494e2b05728351858aa283a569caa5b
4
- data.tar.gz: d5abea27b67b2501f16819de68c5716350423940
3
+ metadata.gz: 3bea91791db9be24a0d7dbb300fd657c4945bd9c
4
+ data.tar.gz: b81af550504897b814940f439a046741718fc880
5
5
  SHA512:
6
- metadata.gz: 63bcb8b0e4b562ed566ea33f286469d11ba5ddce18f59cb58b66e45d5b78d94bc0643c171b8375d6d6a5d10d19aec7a5678cd42d15ab657aa53519fe05c13005
7
- data.tar.gz: 8a0768e8cfe086e62ada27b327e1b9a049c4825efd0fdb925a9f6ccc85ef3873ba06a79a757ee27014bb13a86adfe6e9c4ec2374d3395f56988193523bd2f5ee
6
+ metadata.gz: 21fca201df25802d84e33b537cc6afafd761c5b35ea8904b5ea74336ed4727e0384abec38b8ef179817a3ff5c7eb929b4037c2c31ebde21d2bd8f4166b5e67d9
7
+ data.tar.gz: b007443b14e1030ac500a59b667d94599ccaee429da3f242f42dff66d03c7fe315f46609f462898e6b3b9245d31a55979a11dff78276a3e11daea70705baf0c4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.7.0
1
+ 1.7.1
@@ -79,7 +79,7 @@ module ActiveFacts
79
79
  def_single_delegator :@hash, :size
80
80
  def_single_delegator :@hash, :empty?
81
81
  def_single_delegator :@hash, :each, 1, 2, -3
82
- def_single_delegator :@hash, :map, 1, 2, -3
82
+ def_single_delegator :@hash, :map, 1, 2, -3, -1
83
83
  def_single_delegator :@hash, :detect, 1
84
84
  def_single_delegator :@hash, :values
85
85
  def_single_delegator :@hash, :keys
@@ -22,35 +22,35 @@ module ActiveFacts
22
22
  attr_reader :value_constraint # Counterpart Instances playing this role must meet this constraint
23
23
 
24
24
  def is_identifying # Is this an identifying role for object_type?
25
- return @is_identifying unless @is_identifying == nil
25
+ return @is_identifying unless @is_identifying == nil
26
26
  @is_identifying = !!(@object_type.is_entity_type && @object_type.identifying_role_names.include?(@name))
27
27
  end
28
28
 
29
29
  def initialize(fact_type, object_type, role_name, mandatory, unique, restrict = nil)
30
- @fact_type = fact_type
31
- @fact_type.all_role << self
30
+ @fact_type = fact_type
31
+ @fact_type.all_role << self
32
32
  @object_type = object_type
33
33
  @name = role_name
34
34
  @mandatory = mandatory
35
35
  @unique = unique
36
- @value_constraint = restrict
37
- object_type.add_role(self)
36
+ @value_constraint = restrict
37
+ object_type.add_role(self)
38
38
  associate_role(@object_type)
39
39
  end
40
40
 
41
41
  # Is this role a unary (created by maybe)?
42
42
  def unary?
43
43
  # N.B. A role with a forward reference looks unary until it is resolved.
44
- @fact_type.all_role.size == 1
44
+ @fact_type.all_role.size == 1
45
45
  end
46
46
 
47
47
  def make_mandatory
48
- # Sometimes a role has already been defined from the other end
49
- @mandatory = true
48
+ # Sometimes a role has already been defined from the other end
49
+ @mandatory = true
50
50
  end
51
51
 
52
52
  def counterpart
53
- @counterpart ||= (@fact_type.all_role - [self])[0]
53
+ @counterpart ||= (@fact_type.all_role - [self])[0]
54
54
  end
55
55
 
56
56
  # Return the name of the getter method
@@ -73,8 +73,8 @@ module ActiveFacts
73
73
  end
74
74
 
75
75
  def verbalise
76
- "Role #{name} of #{object_type}, " +
77
- (unary? ? 'unary' : (counterpart ? 'played by' + counterpart.object_type : 'undefined'))
76
+ "Role #{name} of #{object_type}, " +
77
+ (unary? ? 'unary' : (counterpart ? 'played by' + counterpart.object_type : 'undefined'))
78
78
  end
79
79
 
80
80
  private
@@ -28,22 +28,22 @@ module ActiveFacts
28
28
 
29
29
  # A value is its own key, unless it's a delegate for a raw value
30
30
  def identifying_role_values(klass = nil) #:nodoc:
31
- # The identifying role value for the supertype of a value type is always the same as for the subtype
32
- respond_to?(:__getobj__) ? __getobj__ : self
31
+ # The identifying role value for the supertype of a value type is always the same as for the subtype
32
+ respond_to?(:__getobj__) ? __getobj__ : self
33
33
  end
34
34
 
35
35
  def plays_no_role
36
- # REVISIT: Some Value Types are independent, and so must always be regarded as playing a role
37
- self.class.all_role.all? do |n, role|
38
- case
39
- when role.fact_type.is_a?(ActiveFacts::API::TypeInheritanceFactType)
40
- true # No need to consider subtyping/supertyping roles here
41
- when role.unique
42
- send(role.getter) == nil
43
- else
44
- send(role.getter).empty?
45
- end
46
- end
36
+ # REVISIT: Some Value Types are independent, and so must always be regarded as playing a role
37
+ self.class.all_role.all? do |n, role|
38
+ case
39
+ when role.fact_type.is_a?(ActiveFacts::API::TypeInheritanceFactType)
40
+ true # No need to consider subtyping/supertyping roles here
41
+ when role.unique
42
+ send(role.getter) == nil
43
+ else
44
+ send(role.getter).empty?
45
+ end
46
+ end
47
47
  end
48
48
 
49
49
  # All ValueType classes include the methods defined here
@@ -53,7 +53,7 @@ module ActiveFacts
53
53
  def value_type *args, &block #:nodoc:
54
54
  options = (args[-1].is_a?(Hash) ? args.pop : {})
55
55
  options.each do |key, value|
56
- raise UnrecognisedOptionsException.new('ValueType', basename, key) unless respond_to?(key)
56
+ raise UnrecognisedOptionsException.new('ValueType', basename, key) unless respond_to?(key)
57
57
  send(key, value)
58
58
  end
59
59
  end
@@ -84,49 +84,49 @@ module ActiveFacts
84
84
  end
85
85
 
86
86
  def identifying_role_values(constellation, args) #:nodoc:
87
- # Normalise positional arguments into an arguments hash (this changes the passed parameter)
88
- arg_hash = args[-1].is_a?(Hash) ? args.pop : {}
87
+ # Normalise positional arguments into an arguments hash (this changes the passed parameter)
88
+ arg_hash = args[-1].is_a?(Hash) ? args.pop : {}
89
89
 
90
90
  # If a single arg is already the correct class or a subclass,
91
- # use it directly, otherwise create one.
92
- # This appears to be the only way to handle e.g. Date correctly
91
+ # use it directly, otherwise create one.
92
+ # This appears to be the only way to handle e.g. Date correctly
93
93
  unless args.size == 1 and instance = args[0] and instance.is_a?(self)
94
- instance = new_instance(constellation, *args)
94
+ instance = new_instance(constellation, *args)
95
95
  end
96
- args.replace([arg_hash])
97
- instance.identifying_role_values(self)
96
+ args.replace([arg_hash])
97
+ instance.identifying_role_values(self)
98
98
  end
99
99
 
100
- def assert_instance(constellation, args)
101
- new_identifier = args == [:new]
102
- key = identifying_role_values(constellation, args)
103
- # args are now normalized to an array containing a single Hash element
104
- arg_hash = args[0]
105
-
106
- if new_identifier
107
- instance = key # AutoCounter is its own key
108
- else
109
- instance_index = constellation.instances[self]
110
- unless instance = constellation.has_candidate(self, key) || instance_index[key]
111
- instance = new_instance(constellation, key)
112
- constellation.candidate(instance)
113
- end
114
- end
115
-
116
- # Assign any extra roles that may have been passed.
100
+ def assert_instance(constellation, args)
101
+ new_identifier = args == [:new]
102
+ key = identifying_role_values(constellation, args)
103
+ # args are now normalized to an array containing a single Hash element
104
+ arg_hash = args[0]
105
+
106
+ if new_identifier
107
+ instance = key # AutoCounter is its own key
108
+ else
109
+ instance_index = constellation.instances[self]
110
+ unless instance = constellation.has_candidate(self, key) || instance_index[key]
111
+ instance = new_instance(constellation, key)
112
+ constellation.candidate(instance)
113
+ end
114
+ end
115
+
116
+ # Assign any extra roles that may have been passed.
117
117
  # These assignments only take effect after the candidate object have been asserted.
118
118
  # An exception here means the object is asserted but the role not assigned.
119
- arg_hash.each do |k, v|
120
- constellation.when_admitted {
121
- instance.send(:"#{k}=", v)
122
- }
123
- end
119
+ arg_hash.each do |k, v|
120
+ constellation.when_admitted {
121
+ instance.send(:"#{k}=", v)
122
+ }
123
+ end
124
124
 
125
- instance
126
- end
125
+ instance
126
+ end
127
127
 
128
128
  def index_instance(constellation, instance) #:nodoc:
129
- # Index the instance in the constellation's InstanceIndex for this class:
129
+ # Index the instance in the constellation's InstanceIndex for this class:
130
130
  instances = constellation.instances[self]
131
131
  key = instance.identifying_role_values(self)
132
132
  instances[key] = instance
@@ -142,7 +142,7 @@ module ActiveFacts
142
142
  def inherited(other) #:nodoc:
143
143
  # Copy the type parameters here, etc?
144
144
  other.send :realise_supertypes, self
145
- TypeInheritanceFactType.new(self, other)
145
+ TypeInheritanceFactType.new(self, other)
146
146
  vocabulary.__add_object_type(other)
147
147
  super
148
148
  end
@@ -167,6 +167,8 @@ module ActiveFacts
167
167
 
168
168
  def initialize *args, &b
169
169
  send(:firstaid_initialize, *args, &b)
170
+ return if NoMethodError === self && message =~ /^undefined method `to_ary' for \#<Gem::Specification/
171
+ return if LoadError == self
170
172
  puts "Stopped due to #{self.class}: #{message} at "+caller*"\n\t"
171
173
  debugger
172
174
  true # Stopped in Exception constructor
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activefacts-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clifford Heath
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2015-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbtree-pure