woody-decorators 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/woody/decorators.rb +1 -1
- data/lib/woody/decorators/challenge.rb +18 -0
- data/lib/woody/decorators/challenge_question.rb +41 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4621116b3ad2e33b268c98c146dc3b138b0f73d5
|
4
|
+
data.tar.gz: e5212ea5b8cb0912419ef4ee944421b4bcd090ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75337929b944b69e856984a511b0effd6dd2a423faa10797ad5f6076ea4355937405f703c8ee1fac7e07fb113c43f9e8f1245bf0716f2bfba8d961e9f197b56f
|
7
|
+
data.tar.gz: 6de295696e362347d39c307056046b1b3145c204b370bc175a25806f2d39a21f631b4a0da6b8893a130b39a5d850fc72de1ee502e354b15e7e54e87608e3db71
|
data/lib/woody/decorators.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require "wes/data/api/brand"
|
2
|
+
require "wes/data/api/challenge"
|
2
3
|
require "woody/decorators/base"
|
4
|
+
require "woody/decorators/challenge_question"
|
3
5
|
|
4
6
|
module Woody
|
5
7
|
module Decorators
|
@@ -8,6 +10,14 @@ module Woody
|
|
8
10
|
brand.name
|
9
11
|
end
|
10
12
|
|
13
|
+
def essentials_questions
|
14
|
+
questions.fetch("essentials", {})
|
15
|
+
end
|
16
|
+
|
17
|
+
def concept_questions
|
18
|
+
questions.fetch("concept", {})
|
19
|
+
end
|
20
|
+
|
11
21
|
def reward_total
|
12
22
|
@model.rewards.inject(0) do |total, reward|
|
13
23
|
total + (reward.quantity * reward.amount)
|
@@ -22,6 +32,14 @@ module Woody
|
|
22
32
|
|
23
33
|
private
|
24
34
|
|
35
|
+
def questions
|
36
|
+
@questions ||= Wes::Data::API::Challenge.questions.map do |question|
|
37
|
+
ChallengeQuestion.new(question, @model.answers)
|
38
|
+
end.group_by do |question|
|
39
|
+
question.section
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
25
43
|
def brand
|
26
44
|
@brand ||= Wes::Data::API::Brand.find(:id, @model.brand_id)
|
27
45
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "woody/decorators/base"
|
2
|
+
|
3
|
+
module Woody
|
4
|
+
module Decorators
|
5
|
+
class ChallengeQuestion < Base
|
6
|
+
def initialize(model, answers)
|
7
|
+
super(model)
|
8
|
+
@answers = answers
|
9
|
+
end
|
10
|
+
|
11
|
+
def answer
|
12
|
+
answer_item = answer_for_question(@model.id)
|
13
|
+
answer_item ? answer_item.answer : ""
|
14
|
+
end
|
15
|
+
|
16
|
+
def has_answer?
|
17
|
+
answer_for_question(@model.id)
|
18
|
+
end
|
19
|
+
|
20
|
+
def text_type?
|
21
|
+
@model.type == "text"
|
22
|
+
end
|
23
|
+
|
24
|
+
def textarea_type?
|
25
|
+
@model.type == "textarea"
|
26
|
+
end
|
27
|
+
|
28
|
+
def number_type?
|
29
|
+
@model.type == "number"
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def answer_for_question(id)
|
35
|
+
@answers.find do |answer|
|
36
|
+
answer.question_id == id
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: woody-decorators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- lib/woody/decorators/base.rb
|
135
135
|
- lib/woody/decorators/brand.rb
|
136
136
|
- lib/woody/decorators/challenge.rb
|
137
|
+
- lib/woody/decorators/challenge_question.rb
|
137
138
|
- lib/woody/decorators/creator_user.rb
|
138
139
|
- lib/woody/decorators/submission.rb
|
139
140
|
- lib/woody/decorators/video.rb
|