Module: ROM::Options::Transformers
- Extended by:
- Transproc::Registry
- Defined in:
- lib/rom/support/options.rb
Overview
Collection of transformers for options
Class Method Summary collapse
- .coercer(_, options, name, fn) ⇒ Object
- .default_proc(object, options, name, fn) ⇒ Object
- .default_value(_, options, name, value) ⇒ Object
- .reader_assigner(object, options, name) ⇒ Object
- .type_checker(_, options, name, type) ⇒ Object
- .value_checker(_, options, name, list) ⇒ Object
Class Method Details
.coercer(_, options, name, fn) ⇒ Object
214 215 216 217 218 |
# File 'lib/rom/support/options.rb', line 214 def self.coercer(_, , name, fn) return unless .key?(name) value = [name] .merge name => fn[value] end |
.default_proc(object, options, name, fn) ⇒ Object
209 210 211 212 |
# File 'lib/rom/support/options.rb', line 209 def self.default_proc(object, , name, fn) return if .key?(name) .merge(name => fn.call(object)) end |
.default_value(_, options, name, value) ⇒ Object
204 205 206 207 |
# File 'lib/rom/support/options.rb', line 204 def self.default_value(_, , name, value) return if .key?(name) .merge(name => value) end |
.reader_assigner(object, options, name) ⇒ Object
243 244 245 246 |
# File 'lib/rom/support/options.rb', line 243 def self.reader_assigner(object, , name) object.instance_variable_set(:"@#{name}", [name]) end |
.type_checker(_, options, name, type) ⇒ Object
220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/rom/support/options.rb', line 220 def self.type_checker(_, , name, type) return unless .key?(name) value = [name] return if [name].is_a?(type) fail( InvalidOptionValueError, "#{name.inspect}:#{value.inspect} has incorrect type" \ " (#{type} is expected)" ) end |
.value_checker(_, options, name, list) ⇒ Object
232 233 234 235 236 237 238 239 240 241 |
# File 'lib/rom/support/options.rb', line 232 def self.value_checker(_, , name, list) return unless .key?(name) value = [name] return if list.include?([name]) fail( InvalidOptionValueError, "#{name.inspect}:#{value.inspect} has incorrect value." ) end |