Module: Schema::Normalize::ClassMethods

Defined in:
lib/schema/normalize.rb

Instance Method Summary collapse

Instance Method Details

#create_schema_model_normalizerObject



15
16
17
18
19
20
21
# File 'lib/schema/normalize.rb', line 15

def create_schema_model_normalizer
  normalizer = ::Schema::ModelNormalizer.new
  schema_normalizations.each do |(attribute_name, method_name, options)|
    normalizer.add(attribute_name, method_name, options)
  end
  normalizer
end

#normalize(attribute_name, method_name, options = {}) ⇒ Object



27
28
29
30
# File 'lib/schema/normalize.rb', line 27

def normalize(attribute_name, method_name, options = {})
  new_value = schema_normalizations.dup << [attribute_name, method_name, options]
  redefine_class_method(:schema_normalizations, new_value)
end

#schema_model_normalizerObject



23
24
25
# File 'lib/schema/normalize.rb', line 23

def schema_model_normalizer
  @schema_model_normalizer ||= create_schema_model_normalizer
end

#schema_normalizationsObject



11
12
13
# File 'lib/schema/normalize.rb', line 11

def schema_normalizations
  [].freeze
end