Module: SmoothOperator::ModelSchema::ClassMethods
- Defined in:
- lib/smooth_operator/model_schema.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #internal_structure ⇒ Object
- #known_attributes ⇒ Object
- #model_name ⇒ Object
- #model_name=(name) ⇒ Object
- #schema(structure) ⇒ Object
Instance Attribute Details
#resource_name ⇒ Object
33 34 35 |
# File 'lib/smooth_operator/model_schema.rb', line 33 def resource_name @resource_name ||= self.model_name.to_s.underscore.pluralize end |
#resources_name ⇒ Object
28 29 30 |
# File 'lib/smooth_operator/model_schema.rb', line 28 def resources_name @resources_name ||= self.resource_name.pluralize end |
Instance Method Details
#internal_structure ⇒ Object
44 45 46 |
# File 'lib/smooth_operator/model_schema.rb', line 44 def internal_structure Helpers.get_instance_variable(self, :internal_structure, {}) end |
#known_attributes ⇒ Object
48 49 50 |
# File 'lib/smooth_operator/model_schema.rb', line 48 def known_attributes Helpers.get_instance_variable(self, :known_attributes, Set.new) end |
#model_name ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/smooth_operator/model_schema.rb', line 52 def model_name return '' if @_model_name == :none if defined? ActiveModel rails_model_name_method else @_model_name ||= name.split('::').last.underscore.capitalize end end |
#model_name=(name) ⇒ Object
62 63 64 |
# File 'lib/smooth_operator/model_schema.rb', line 62 def model_name=(name) @_model_name = name end |
#schema(structure) ⇒ Object
38 39 40 41 42 |
# File 'lib/smooth_operator/model_schema.rb', line 38 def schema(structure) internal_structure.merge! Helpers.stringify_keys(structure) known_attributes.merge internal_structure.keys end |