Module: Anchor::Types

Defined in:
lib/anchor/types.rb

Defined Under Namespace

Modules: Inference Classes: Array, BigDecimal, Boolean, Enum, Float, Identity, Integer, Intersection, Literal, Maybe, Null, Object, Property, Record, Reference, Relationship, String, Union, Unknown

Class Method Summary collapse

Class Method Details

.camelize_without_inflection(val) ⇒ Object



217
218
219
220
221
222
223
224
# File 'lib/anchor/types.rb', line 217

def self.camelize_without_inflection(val)
  vals = val.split("_")
  if vals.length == 1
    vals[0]
  else
    ([vals[0]] + vals[1..].map(&:capitalize)).join("")
  end
end

.convert_case(value) ⇒ String

Parameters:

Returns:



228
229
230
231
232
233
234
235
236
# File 'lib/anchor/types.rb', line 228

def self.convert_case(value)
  case Anchor.config.field_case
  when :camel then value.to_s.underscore.camelize(:lower)
  when :camel_without_inflection then camelize_without_inflection(value.to_s.underscore)
  when :kebab then value.to_s.underscore.dasherize
  when :snake then value.to_s.underscore
  else value
  end
end