Class: GrowViral::Warehouse::RegistersFollows
- Inherits:
-
Object
- Object
- GrowViral::Warehouse::RegistersFollows
- Defined in:
- lib/warehouse/registers_followers.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#following_uid ⇒ Object
readonly
Returns the value of attribute following_uid.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
Class Method Summary collapse
Instance Method Summary collapse
- #form_data ⇒ Object
-
#initialize(uid, following_uid, deps) ⇒ RegistersFollows
constructor
A new instance of RegistersFollows.
- #register ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(uid, following_uid, deps) ⇒ RegistersFollows
Returns a new instance of RegistersFollows.
9 10 11 12 13 14 15 16 |
# File 'lib/warehouse/registers_followers.rb', line 9 def initialize(uid, following_uid, deps) raise HandleNotUidError unless uid.is_a? Numeric raise HandleNotUidError unless following_uid.is_a? Numeric @uid = uid @following_uid = following_uid @config = deps[:config] end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/warehouse/registers_followers.rb', line 8 def config @config end |
#following_uid ⇒ Object (readonly)
Returns the value of attribute following_uid.
8 9 10 |
# File 'lib/warehouse/registers_followers.rb', line 8 def following_uid @following_uid end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
8 9 10 |
# File 'lib/warehouse/registers_followers.rb', line 8 def uid @uid end |
Class Method Details
.register(*args) ⇒ Object
4 5 6 |
# File 'lib/warehouse/registers_followers.rb', line 4 def self.register(*args) new(*args).register end |
Instance Method Details
#form_data ⇒ Object
27 28 29 30 31 32 |
# File 'lib/warehouse/registers_followers.rb', line 27 def form_data { "uid" => uid, "following_uid" => following_uid } end |
#register ⇒ Object
18 19 20 21 |
# File 'lib/warehouse/registers_followers.rb', line 18 def register response = Net::HTTP.post_form(uri, form_data) JSON.parse(response.body) end |
#uri ⇒ Object
23 24 25 |
# File 'lib/warehouse/registers_followers.rb', line 23 def uri @uri ||= URI.parse("#{config.host}/follows") end |