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_handle ⇒ Object
readonly
Returns the value of attribute following_handle.
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
Class Method Summary collapse
Instance Method Summary collapse
- #form_data ⇒ Object
-
#initialize(handle, following_handle, deps) ⇒ RegistersFollows
constructor
A new instance of RegistersFollows.
- #register ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(handle, following_handle, deps) ⇒ RegistersFollows
Returns a new instance of RegistersFollows.
9 10 11 12 13 |
# File 'lib/warehouse/registers_followers.rb', line 9 def initialize(handle, following_handle, deps) @handle = handle @following_handle = following_handle @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_handle ⇒ Object (readonly)
Returns the value of attribute following_handle.
8 9 10 |
# File 'lib/warehouse/registers_followers.rb', line 8 def following_handle @following_handle end |
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
8 9 10 |
# File 'lib/warehouse/registers_followers.rb', line 8 def handle @handle 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
24 25 26 27 28 29 |
# File 'lib/warehouse/registers_followers.rb', line 24 def form_data { "handle" => handle, "following_handle" => following_handle } end |
#register ⇒ Object
15 16 17 18 |
# File 'lib/warehouse/registers_followers.rb', line 15 def register response = Net::HTTP.post_form(uri, form_data) JSON.parse(response.body) end |
#uri ⇒ Object
20 21 22 |
# File 'lib/warehouse/registers_followers.rb', line 20 def uri @uri ||= URI.parse("#{config.host}/follows") end |