Class: AppReview

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_app_reviews/app_review.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_attributes, app = nil) ⇒ AppReview

Returns a new instance of AppReview.



6
7
8
9
10
11
12
# File 'lib/shopify_app_reviews/app_review.rb', line 6

def initialize(app_attributes, app = nil)
  @title = app_attributes[:title]
  @body = app_attributes[:body]
  @date = app_attributes[:date]
  @rating = app_attributes[:rating]
  @app = app if app
end

Instance Attribute Details

#appObject

Returns the value of attribute app.



2
3
4
# File 'lib/shopify_app_reviews/app_review.rb', line 2

def app
  @app
end

#bodyObject

Returns the value of attribute body.



2
3
4
# File 'lib/shopify_app_reviews/app_review.rb', line 2

def body
  @body
end

#dateObject

Returns the value of attribute date.



2
3
4
# File 'lib/shopify_app_reviews/app_review.rb', line 2

def date
  @date
end

#ratingObject

Returns the value of attribute rating.



2
3
4
# File 'lib/shopify_app_reviews/app_review.rb', line 2

def rating
  @rating
end

#titleObject

Returns the value of attribute title.



2
3
4
# File 'lib/shopify_app_reviews/app_review.rb', line 2

def title
  @title
end

Class Method Details

.allObject



14
15
16
# File 'lib/shopify_app_reviews/app_review.rb', line 14

def self.all
  @@all
end

.create(app_attributes, app = nil) ⇒ Object



26
27
28
29
# File 'lib/shopify_app_reviews/app_review.rb', line 26

def self.create(app_attributes, app = nil)
  a = self.new(app_attributes, app)
  a.save
end

.create_from_collection(review_array, app) ⇒ Object



36
37
38
39
40
# File 'lib/shopify_app_reviews/app_review.rb', line 36

def self.create_from_collection(review_array, app)
  review_array.each do |review_info|
    self.create(review_info, app)
  end
end

.destroy_allObject



18
19
20
# File 'lib/shopify_app_reviews/app_review.rb', line 18

def self.destroy_all
  self.class.all.clear
end

Instance Method Details

#saveObject



22
23
24
# File 'lib/shopify_app_reviews/app_review.rb', line 22

def save
  self.class.all << self
end