Class: Serega::SeregaPlugins::CamelCase::CamelCaseConfig
- Inherits:
-
Object
- Object
- Serega::SeregaPlugins::CamelCase::CamelCaseConfig
- Defined in:
- lib/serega/plugins/camel_case/camel_case.rb
Overview
CamelCase config object
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
-
#initialize(opts) ⇒ Serega::SeregaPlugins::CamelCase::CamelCaseConfig
constructor
Initializes CamelCaseConfig object.
-
#transform ⇒ #call
Defined object that transforms name.
-
#transform=(value) ⇒ #call
Sets transformation callable object.
Constructor Details
#initialize(opts) ⇒ Serega::SeregaPlugins::CamelCase::CamelCaseConfig
Initializes CamelCaseConfig object
145 146 147 |
# File 'lib/serega/plugins/camel_case/camel_case.rb', line 145 def initialize(opts) @opts = opts end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
135 136 137 |
# File 'lib/serega/plugins/camel_case/camel_case.rb', line 135 def opts @opts end |
Instance Method Details
#transform ⇒ #call
Returns defined object that transforms name.
150 151 152 |
# File 'lib/serega/plugins/camel_case/camel_case.rb', line 150 def transform opts.fetch(:transform) end |
#transform=(value) ⇒ #call
Sets transformation callable object
159 160 161 162 163 164 165 166 167 168 |
# File 'lib/serega/plugins/camel_case/camel_case.rb', line 159 def transform=(value) raise SeregaError, "Transform value must respond to #call" unless value.respond_to?(:call) params = value.is_a?(Proc) ? value.parameters : value.method(:call).parameters if params.count != 1 || !params.all? { |param| (param[0] == :req) || (param[0] == :opt) } raise SeregaError, "Transform value must respond to #call and accept 1 regular parameter" end opts[:transform] = value end |