Module: Spree::Metafields::ClassMethods
- Defined in:
- app/models/concerns/spree/metafields.rb
Instance Method Summary collapse
- #ensure_metafield_definition_exists!(key_with_namespace) ⇒ Object
- #extract_namespace_and_key(key_with_namespace) ⇒ Object
Instance Method Details
#ensure_metafield_definition_exists!(key_with_namespace) ⇒ Object
6 7 8 9 |
# File 'app/models/concerns/spree/metafields.rb', line 6 def (key_with_namespace) namespace, key = extract_namespace_and_key(key_with_namespace) Spree::MetafieldDefinition.find_or_create_by!(namespace: namespace, key: key, resource_type: self.name) end |
#extract_namespace_and_key(key_with_namespace) ⇒ Object
11 12 13 14 15 |
# File 'app/models/concerns/spree/metafields.rb', line 11 def extract_namespace_and_key(key_with_namespace) namespace = key_with_namespace.to_s.split('.').first key = key_with_namespace.to_s.split('.').last [namespace, key] end |