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
163 164 165 |
# File 'lib/serega/plugins/camel_case/camel_case.rb', line 163 def initialize(opts) @opts = opts end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
153 154 155 |
# File 'lib/serega/plugins/camel_case/camel_case.rb', line 153 def opts @opts end |
Instance Method Details
#transform ⇒ #call
Returns defined object that transforms name.
168 169 170 |
# File 'lib/serega/plugins/camel_case/camel_case.rb', line 168 def transform opts.fetch(:transform) end |
#transform=(value) ⇒ #call
Sets transformation callable object
177 178 179 180 181 182 183 184 185 186 |
# File 'lib/serega/plugins/camel_case/camel_case.rb', line 177 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 |