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(default_bypass = nil) ⇒ Object
26 27 28 29 30 |
# File 'lib/smooth_operator/model_schema.rb', line 26 def resource_name(default_bypass = nil) return @resource_name if defined?(@resource_name) (Helpers.super_method(self, :resource_name, true) || (default_bypass ? nil : self.model_name.to_s.underscore)) end |
#resources_name(default_bypass = nil) ⇒ Object
19 20 21 22 23 |
# File 'lib/smooth_operator/model_schema.rb', line 19 def resources_name(default_bypass = nil) return @resources_name if defined?(@resources_name) (Helpers.super_method(self, :resources_name, true) || (default_bypass ? nil : self.resource_name.pluralize)) end |
Instance Method Details
#internal_structure ⇒ Object
39 40 41 |
# File 'lib/smooth_operator/model_schema.rb', line 39 def internal_structure Helpers.get_instance_variable(self, :internal_structure, { "errors" => nil }) end |
#known_attributes ⇒ Object
43 44 45 |
# File 'lib/smooth_operator/model_schema.rb', line 43 def known_attributes Helpers.get_instance_variable(self, :known_attributes, Set.new) end |
#model_name ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/smooth_operator/model_schema.rb', line 47 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
57 58 59 |
# File 'lib/smooth_operator/model_schema.rb', line 57 def model_name=(name) @_model_name = name end |
#schema(structure) ⇒ Object
33 34 35 36 37 |
# File 'lib/smooth_operator/model_schema.rb', line 33 def schema(structure) internal_structure.merge! Helpers.stringify_keys(structure) known_attributes.merge internal_structure.keys end |