Class: RailsWizard::Config::Prompt
- Inherits:
-
Object
- Object
- RailsWizard::Config::Prompt
show all
- Defined in:
- lib/rails_wizard/config.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(details) ⇒ Prompt
Returns a new instance of Prompt.
32
33
34
35
|
# File 'lib/rails_wizard/config.rb', line 32
def initialize(details)
@details = details
@prompt = details['prompt']
end
|
Instance Attribute Details
#details ⇒ Object
Returns the value of attribute details.
31
32
33
|
# File 'lib/rails_wizard/config.rb', line 31
def details
@details
end
|
#prompt ⇒ Object
Returns the value of attribute prompt.
31
32
33
|
# File 'lib/rails_wizard/config.rb', line 31
def prompt
@prompt
end
|
Instance Method Details
#compile ⇒ Object
37
38
39
|
# File 'lib/rails_wizard/config.rb', line 37
def compile
"#{question} if #{conditions}"
end
|
#conditions ⇒ Object
45
46
47
|
# File 'lib/rails_wizard/config.rb', line 45
def conditions
[config_conditions, recipe_conditions].join(' && ')
end
|
#config_conditions ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'lib/rails_wizard/config.rb', line 49
def config_conditions
if details['if']
"config['#{details['if']}']"
elsif details['unless']
"!config['#{details['unless']}']"
else
'true'
end
end
|
#question ⇒ Object
41
42
43
|
# File 'lib/rails_wizard/config.rb', line 41
def question
"ask_wizard(#{prompt.inspect})"
end
|
#recipe_conditions ⇒ Object
59
60
61
62
63
64
65
66
67
|
# File 'lib/rails_wizard/config.rb', line 59
def recipe_conditions
if details['if_recipe']
"recipe?('#{details['if_recipe']}')"
elsif details['unless_recipe']
"!recipe?('#{details['unless_recipe']}')"
else
'true'
end
end
|