Class: GrowViral::Warehouse::RegistersFollows

Inherits:
Object
  • Object
show all
Defined in:
lib/warehouse/registers_followers.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uid, following_uid, deps) ⇒ RegistersFollows

Returns a new instance of RegistersFollows.

Raises:



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

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/warehouse/registers_followers.rb', line 8

def config
  @config
end

#following_uidObject (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

#uidObject (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_dataObject



27
28
29
30
31
32
# File 'lib/warehouse/registers_followers.rb', line 27

def form_data
  {
    "uid" => uid,
    "following_uid" => following_uid
  }
end

#registerObject



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

#uriObject



23
24
25
# File 'lib/warehouse/registers_followers.rb', line 23

def uri
  @uri ||= URI.parse("#{config.host}/follows")
end