Module: Sandboxy::Sandboxed::InstanceMethods
- Defined in:
- lib/sandboxy/sandboxed.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
50
51
52
53
54
55
56
57
58
|
# File 'lib/sandboxy/sandboxed.rb', line 50
def method_missing m, *args
if m.to_s[/move_environment_(.+)/]
self.move_environment $1
elsif m.to_s[/(.+)_environment?/]
self.environment? $1
else
super
end
end
|
Instance Method Details
#environment ⇒ Object
85
86
87
88
|
# File 'lib/sandboxy/sandboxed.rb', line 85
def environment
return Sandboxy.configuration.default if self.sandbox.nil?
self.sandbox.environment
end
|
#environment?(value) ⇒ Boolean
81
82
83
|
# File 'lib/sandboxy/sandboxed.rb', line 81
def environment? value
self.environment == value
end
|
#move_environment(value) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/sandboxy/sandboxed.rb', line 64
def move_environment value
case value
when Sandboxy.configuration.default
Sandbox.where(sandboxed_id: self.id, sandboxed_type: self.class.name).destroy_all
self.sandbox = nil
self.save!
else
unless self.sandbox.nil?
self.sandbox.update_attributes environment: value
else
sandbox = self.build_sandbox
sandbox.environment = value
sandbox.save!
end
end
end
|
#respond_to?(m, include_private = false) ⇒ Boolean
60
61
62
|
# File 'lib/sandboxy/sandboxed.rb', line 60
def respond_to? m, include_private = false
super || m.to_s[/move_environment_(.+)/] || m.to_s[/(.+)_environment?/]
end
|