-
Notifications
You must be signed in to change notification settings - Fork 26
Helper methods
Return ActiveRecord::Relation object with prepared query to receive attributes for current entity
Product.hydra_attributes # return attribute models
Product.hydra_attributes.create(name: 'title', backend_type: 'string') # create attributes
Product.hydra_attributes.map(&:destroy) # destroy all attributesFind attribute by ID or name. Return nil for unknown attribute.
Product.hydra_attribute('title')
# <HydraAttribute::HydraAttribute...>
Product.hydra_attribute(10)
# nilReturn array of attribute backend types for current entity. This method is cacheable so it is better to use it than determine values from .hydra_attributes object.
Product.hydra_attribute_backend_types
# ["string", "integer"]Return array of attribute names for current entity. This method is cacheable so it is better to use it than determine values from .hydra_attributes object.
Product.hydra_attribute_names
# ["title", "price"]Return array of attribute ids for current entity. This method is cacheable so it is better to use it than determine values from .hydra_attributes object.
Product.hydra_attribute_ids
# [1, 2, 4]Return hash where keys are backend types and values are array of attributes. This method is cacheable so it is better to use it than determine values from .hydra_attributes object.
Product.hydra_attributes_by_backend_type
# {"string"=>[<HydraAttribute::HydraAttribute...>, ...]}Return hash where keys are backend types and values are array of attribute names. This method is cacheable so it is better to use it than determine values from .hydra_attributes object.
Product.hydra_attribute_names_by_backend_type
# {"string"=>["title", "price"]}Return hash where keys are backend types and values are array of attribute ids. This method is cacheable so it is better to use it than determine values from .hydra_attributes object.
Product.hydra_attribute_ids_by_backend_type
# {"string"=>[1, 2, 4]}Return array of attributes for specific backend type.
Product.hydra_attrbiutes_for_backend_type('string')
# [<HydraAttribute::HydraAttribute...>, ...]
Product.hydra_attrbiutes_for_backend_type('integer')
# []Return array of attribute names for specific backend type.
Product.hydra_attrbiute_names_for_backend_type('string')
# ['title', 'code']Return array of attribute ids for specific backend type.
Product.hydra_attrbiute_ids_for_backend_type('string')
# [1, 4]Return ActiveRecord::Relation object with prepared query to receive attribute sets for current entity
Product.hydra_sets # return attribute set models
Product.hydra_sets.create(name: 'Default') # create attribute set
Product.hydra_sets.map(&:destroy) # destroy all attribute setsFind attribute set by ID or name for current entity.
Product.hydra_set('Default')
# <HydraAttribute::HydraSet...>
Product.hydra_set(10)
# nilReturn array with all attribute set ids for current entity.
Product.hydra_set_ids
# [1, 2, 10]Return array with all attribute set names for current entity.
Product.hydra_set_names
# ["Default", "General"]Return collection of attributes which are assigned to current attribute set. If current attribute set doesn't exist, return all attributes for current entity.
Product.hydra_set_attributes('Default') # return attributes for attribute set
Product.hydra_set_attributes('Fake') # the same as Prodct.hydra_attributesReturn array of attribute backend types which are assigned to current attribute set. If current attribute set doesn't exist, return all attribute backend types for current entity.
Product.hydra_set_attribute_backend_types('Default') # return attribute backend types which are assigned to current attribute set
Product.hydra_set_attribute_backend_types('Fake') # The same as Product.hydra_attribute_backend_typesReturn array of attribute ids which are assigned to current attribute set. If current attribute set doesn't exist, return all attribute ids for current entity.
Product.hydra_set_attribute_ids('Default') # return attribute ids which are assigned to current attribute set
Product.hydra_set_attribute_ids('Fake') # The same as Product.hydra_attribute_idsReturn array of attribute names which are assigned to current attribute set. If current attribute set doesn't exist, return all attribute ids for current entity.
Product.hydra_set_attribute_names('Default') # return attribute names which are assigned to current attribute set
Product.hydra_set_attribute_names('Fake') # The same as Product.hydra_attribute_names