Top Level Namespace
Defined Under Namespace
Modules: VagrantPlugins
Classes: Hash, InvalidValue
Instance Method Summary
collapse
Instance Method Details
#casting_attr_accessor(accessor, type, *validators) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/vagrant-openstack-cloud-provider/utils.rb', line 9
def casting_attr_accessor(accessor, type, *validators)
define_method(accessor) do
instance_variable_get("@#{accessor}")
end
define_method("#{accessor}=") do |val|
new_val = Kernel.send(type.to_s, val)
if validators and ! validators.all? {|v| v.call(new_val) }
raise InvalidValue, val
end
instance_variable_set("@#{accessor}", new_val)
end
end
|
#greater_than(base_value) ⇒ Object
4
5
6
|
# File 'lib/vagrant-openstack-cloud-provider/utils.rb', line 4
def greater_than(base_value)
lambda { |val| val > base_value }
end
|