Class: Coolsms::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/coolsms/group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, conditions_hash = {}) ⇒ Group

Returns a new instance of Group.



5
6
7
8
9
# File 'lib/coolsms/group.rb', line 5

def initialize(id, conditions_hash = {})
  @id = id
  @arr = []
  @conditions_hash = conditions_hash.with_indifferent_access
end

Instance Attribute Details

#conditions_hashObject (readonly)

Returns the value of attribute conditions_hash.



3
4
5
# File 'lib/coolsms/group.rb', line 3

def conditions_hash
  @conditions_hash
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/coolsms/group.rb', line 3

def id
  @id
end

Instance Method Details

#allObject



15
16
17
18
19
# File 'lib/coolsms/group.rb', line 15

def all
  return @all if @all
  recursive_next(1)
  @all = @arr.map(&:data).flatten
end

#firstObject



21
22
23
# File 'lib/coolsms/group.rb', line 21

def first
  page(1).data.first
end

#page(num) ⇒ Object



11
12
13
# File 'lib/coolsms/group.rb', line 11

def page(num)
  @arr[num] ||= Finder.new(conditions_hash.merge(group_id: id))
end