Class: VagrantBindfs::Bindfs::OptionSet
- Inherits:
-
Object
- Object
- VagrantBindfs::Bindfs::OptionSet
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/vagrant-bindfs/bindfs/option_set.rb
Instance Attribute Summary collapse
-
#invalid_options ⇒ Object
readonly
Returns the value of attribute invalid_options.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#unsupported_options ⇒ Object
readonly
Returns the value of attribute unsupported_options.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
- .bindfs_options ⇒ Object
- .compatible_name_for_version(option_name, version) ⇒ Object
- .supported_options(version) ⇒ Object
Instance Method Summary collapse
-
#initialize(version = nil, options = {}) ⇒ OptionSet
constructor
A new instance of OptionSet.
- #merge(other) ⇒ Object
- #merge!(other) ⇒ Object
- #to_version(new_version) ⇒ Object
Constructor Details
#initialize(version = nil, options = {}) ⇒ OptionSet
Returns a new instance of OptionSet.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vagrant-bindfs/bindfs/option_set.rb', line 18 def initialize(version = nil, = {}) @version = version @options = normalize_option_names() @invalid_options = {} @unsupported_options = {} cast_option_values! end |
Instance Attribute Details
#invalid_options ⇒ Object (readonly)
Returns the value of attribute invalid_options.
11 12 13 |
# File 'lib/vagrant-bindfs/bindfs/option_set.rb', line 11 def @invalid_options end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/vagrant-bindfs/bindfs/option_set.rb', line 10 def @options end |
#unsupported_options ⇒ Object (readonly)
Returns the value of attribute unsupported_options.
12 13 14 |
# File 'lib/vagrant-bindfs/bindfs/option_set.rb', line 12 def @unsupported_options end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
8 9 10 |
# File 'lib/vagrant-bindfs/bindfs/option_set.rb', line 8 def version @version end |
Class Method Details
.bindfs_options ⇒ Object
108 109 110 |
# File 'lib/vagrant-bindfs/bindfs/option_set.rb', line 108 def @bindfs_options ||= JSON.parse(File.read(File.('option_definitions.json', __dir__))) end |
.compatible_name_for_version(option_name, version) ⇒ Object
119 120 121 122 123 124 |
# File 'lib/vagrant-bindfs/bindfs/option_set.rb', line 119 def compatible_name_for_version(option_name, version) return 'user' if option_name == 'force-user' && version_lower_than(version, '1.12') return 'group' if option_name == 'force-group' && version_lower_than(version, '1.12') option_name end |
.supported_options(version) ⇒ Object
112 113 114 115 116 117 |
# File 'lib/vagrant-bindfs/bindfs/option_set.rb', line 112 def (version) .each_with_object({}) do |(name, definition), supported| supported[name] = definition if version.nil? || !version_lower_than(version, definition['since']) supported end end |
Instance Method Details
#merge(other) ⇒ Object
38 39 40 |
# File 'lib/vagrant-bindfs/bindfs/option_set.rb', line 38 def merge(other) dup.tap { |result| result.merge!(other) } end |
#merge!(other) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/vagrant-bindfs/bindfs/option_set.rb', line 29 def merge!(other) other = other.to_version(version) if other.respond_to?(:to_version) @options.merge!(normalize_option_names(other)) cast_option_values! end |
#to_version(new_version) ⇒ Object
42 43 44 |
# File 'lib/vagrant-bindfs/bindfs/option_set.rb', line 42 def to_version(new_version) self.class.new(new_version, @options.merge().merge()) end |