Module: SmoothOperator::ModelSchema::ClassMethods

Defined in:
lib/smooth_operator/model_schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#table_nameObject



30
31
32
# File 'lib/smooth_operator/model_schema.rb', line 30

def table_name
  @table_name ||= self.model_name.to_s.underscore.pluralize
end

Instance Method Details

#internal_structureObject



40
41
42
# File 'lib/smooth_operator/model_schema.rb', line 40

def internal_structure
  Helpers.get_instance_variable(self, :internal_structure, {})
end

#known_attributesObject



44
45
46
# File 'lib/smooth_operator/model_schema.rb', line 44

def known_attributes
  Helpers.get_instance_variable(self, :known_attributes, Set.new)
end

#model_nameObject



48
49
50
51
52
53
54
# File 'lib/smooth_operator/model_schema.rb', line 48

def model_name
  if defined? ActiveModel
    rails_model_name_method
  else
    @_model_name_namespace ||= name.split('::').last.underscore.capitalize
  end
end

#model_name=(name) ⇒ Object



56
57
58
# File 'lib/smooth_operator/model_schema.rb', line 56

def model_name=(name)
  @_model_name_namespace = name
end

#schema(structure) ⇒ Object



34
35
36
37
38
# File 'lib/smooth_operator/model_schema.rb', line 34

def schema(structure)
  internal_structure.merge! Helpers.stringify_keys(structure)

  known_attributes.merge internal_structure.keys
end