get_your_rep 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +1 -0
- data/lib/get_your_rep/associations.rb +1 -11
- data/lib/get_your_rep/delegation.rb +0 -1
- data/lib/get_your_rep/office_location.rb +0 -9
- data/lib/get_your_rep/representative.rb +0 -11
- data/lib/get_your_rep/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0388947f306d533d91278127114e1370683aed23'
|
4
|
+
data.tar.gz: 2421a7f952d3bfec07f606cde2d84e0df4aab870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d23670e51f645fa8e321c458a45c27d7ef607efdbf784f17e961b569668aba2d357f47eefd08a44dad1b3b4c0c6b80e7e2b8300478848c038058337c1a171e2
|
7
|
+
data.tar.gz: 6f3433654afe83758ce0c52b314f7a38f5aa95811230febadad99b5ea1ea776025b1d96f2e4e8b566fd09925906651e7bd72b216f43e1e54deb8ab3e079f558d
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[![Code Climate](https://codeclimate.com/github/msimonborg/get-your-rep/badges/gpa.svg)](https://codeclimate.com/github/msimonborg/get-your-rep)
|
1
2
|
# Get yo' rep!
|
2
3
|
|
3
4
|
This is the companion [gem](https://rubygems.org/gems/get_your_rep) for the [Phone Your Rep API] (https://github.com/msimonborg/phone-your-rep-api)
|
@@ -3,19 +3,9 @@
|
|
3
3
|
module GetYourRep
|
4
4
|
# Methods for making associations between objects.
|
5
5
|
module Associations
|
6
|
-
def add_child(other:, model:, children:,
|
6
|
+
def add_child(other:, model:, children:, error:)
|
7
7
|
if other.is_a?(model)
|
8
8
|
instance_variable_get("@#{children}") << other
|
9
|
-
other.send("#{parent}=", self) unless other.send(parent.to_s) == self
|
10
|
-
else
|
11
|
-
error.call
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def add_parent(other:, model:, parent:, child:, error:)
|
16
|
-
if other.is_a?(model)
|
17
|
-
instance_variable_set("@#{parent}", other)
|
18
|
-
other.send("add_#{child}", self) unless other.send("#{child}s").include?(self)
|
19
9
|
else
|
20
10
|
error.call
|
21
11
|
end
|
@@ -25,15 +25,6 @@ module GetYourRep
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
# Set the rep attribute to an instance of a Representative, and make two-way association.
|
29
|
-
def rep=(other)
|
30
|
-
add_parent other: other,
|
31
|
-
model: Representative,
|
32
|
-
parent: :rep,
|
33
|
-
child: :office_location,
|
34
|
-
error: -> { not_a_rep_error }
|
35
|
-
end
|
36
|
-
|
37
28
|
# Display self attributes for CLI.
|
38
29
|
def cli_display
|
39
30
|
puts " #{type.capitalize} Office".bold.blue
|
@@ -22,16 +22,6 @@ module GetYourRep
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
# Sets the Delegation object that the instance belongs to. Will add self to the Delegation's
|
26
|
-
# reps if not done so already.
|
27
|
-
def delegation=(other)
|
28
|
-
add_parent other: other,
|
29
|
-
model: Delegation,
|
30
|
-
parent: :delegation,
|
31
|
-
child: :rep,
|
32
|
-
error: -> { not_a_del_error }
|
33
|
-
end
|
34
|
-
|
35
25
|
# Returns a frozen duplicate of the office_locations array.
|
36
26
|
def office_locations
|
37
27
|
@office_locations.dup.freeze
|
@@ -47,7 +37,6 @@ module GetYourRep
|
|
47
37
|
add_child other: other,
|
48
38
|
model: OfficeLocation,
|
49
39
|
children: :office_locations,
|
50
|
-
parent: :rep,
|
51
40
|
error: -> { not_an_office_error }
|
52
41
|
end
|
53
42
|
|
data/lib/get_your_rep/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: get_your_rep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- msimonborg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|