This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am anderslime on github. | |
* I am anderslime (https://keybase.io/anderslime) on keybase. | |
* I have a public key ASDRw8omoxsupCOOTodV5rb_ZK95b5xIJJLhrmQWhX1Grgo | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Contact < Struct.new(:email, :password); end | |
# 1: It has a #to_a method that returns an array | |
# of the values of the Struct. | |
contact = Contact.new("my@email.dk", "secret") | |
Array(contact) # => ["my@email.dk", "secret"] | |
# 2: It sets all initialization arguments to nil as default | |
Contact.new # => #<struct Contact email=nil password=nil> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider_id = 4 | |
contact = Contact.find_by_name_and_provider_id("Jakob Kristensen", provider_id) | |
locations = | |
Location. | |
active. | |
where(:provider_id => provider_id). | |
select {|location| location.primary_contact == contact } |