Class: EPlat::Metafield
- Defined in:
- lib/e_plat/resource/metafield.rb
Direct Known Subclasses
Bigcommerce::Metafield, Shopify::Metafield, ShopifyWebhook::Metafield
Constant Summary collapse
- BIGCOMMERCE_DEFAULT_PERMISSION_SET =
"read_and_sf_access"
- READ_ONLY_ATTRIBUTES =
[:created_at, :id, :updated_at, :date_created, :date_modified]
Constants included from Concerns::GraphQLable
Concerns::GraphQLable::FILTER_ARGS, Concerns::GraphQLable::QUERY_ARG_ARGS
Instance Attribute Summary
Attributes inherited from Base
Attributes included from Concerns::Aliases
Instance Method Summary collapse
- #collection_path(options = {}) ⇒ Object
- #element_path(options = {}) ⇒ Object
- #normalize_attributes ⇒ Object
- #parent_class ⇒ Object
Methods inherited from Base
cached_shopify_webhook?, client, #client, exclude_from_json, #formatted_id, #graphql_input, #headers, #include_root_in_json, inherited, #initialize, initialize_singleton!, #mapped?, #native_keys, platform_specific_class?, prefix=, #read_only?
Methods included from Countable
Methods included from Concerns::GraphQLable
#graphql_mutation_string, #mutate_graphql, #remove_mutation_root_from
Methods included from Concerns::Aliases
Methods included from Concerns::FullJson
Methods included from Concerns::OverwriteRequestMethods
Methods included from Concerns::OverwriteInstanceMethods
#as_eplat_json, #as_json, #create, #create_resource_for, #to_eplat_json, #to_json, #update
Constructor Details
This class inherits a constructor from EPlat::Base
Instance Method Details
#collection_path(options = {}) ⇒ Object
28 29 30 31 32 |
# File 'lib/e_plat/resource/metafield.rb', line 28 def collection_path( = {}) raise "owner_id is not defined" unless owner_id.present? super() end |
#element_path(options = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/e_plat/resource/metafield.rb', line 22 def element_path( = {}) raise "owner_id is not defined" unless owner_id.present? super() end |
#normalize_attributes ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/e_plat/resource/metafield.rb', line 34 def normalize_attributes attributes.each {|k,v| attribute_will_change!(k) if READ_ONLY_ATTRIBUTES.exclude?(k.to_sym) } return unless client.bigcommerce? if .nil? self. = BIGCOMMERCE_DEFAULT_PERMISSION_SET end if value? self.value = value.to_s self.value = "" if value == "false" end end |
#parent_class ⇒ Object
49 50 51 52 53 |
# File 'lib/e_plat/resource/metafield.rb', line 49 def parent_class raise "owner_resource is not defined" unless owner_resource.present? client.platform_klass("EPlat::#{ owner_resource.classify }") || "EPlat::#{ owner_resource.classify }".constantize # e.g EPlat::Product end |