Class: ExportedCatalogItemPacketImageAttribute

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/exported_catalog_item_packet_image_attribute.rb

Overview

== Schema Information

Table name: exported_catalog_item_packet_image_attributes
Database name: primary

id :integer not null, primary key
image_source :string default("website")
mode :string default("profile")
quantity :integer default(20)
selected :boolean default(FALSE)
tag :string
created_at :datetime not null
updated_at :datetime not null
exported_catalog_item_packet_id :integer

Indexes

ecip_id_selected (exported_catalog_item_packet_id,selected)

Constant Summary collapse

MODES =

Modes.

%w[profile tag].freeze
CORE_TAGS =

Recognised core tags.

%w[main product_shot lifestyle].map { |s| s.parameterize.dasherize.capitalize }.freeze
IMAGE_SOURCES =

Image sources.

%w[website amazon walmart].freeze

Constants included from Models::Schedulable

Models::Schedulable::SIMPLE_FORM_OPTIONS

Instance Attribute Summary collapse

Belongs to collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#image_sourceString (readonly)

Returns:

  • (String)


39
# File 'app/models/exported_catalog_item_packet_image_attribute.rb', line 39

validates :image_source, inclusion: { in: IMAGE_SOURCES }, allow_blank: true

#modeString (readonly)

Returns:

  • (String)


37
# File 'app/models/exported_catalog_item_packet_image_attribute.rb', line 37

validates :mode, inclusion: { in: MODES }

Instance Method Details

#exported_catalog_item_packetExportedCatalogItemPacket?

Returns:



23
# File 'app/models/exported_catalog_item_packet_image_attribute.rb', line 23

belongs_to :exported_catalog_item_packet, inverse_of: :exported_catalog_item_packet_image_attributes, optional: true

#profile_mode?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/models/exported_catalog_item_packet_image_attribute.rb', line 42

def profile_mode?
  mode == "profile"
end

#retrieve_images(item) ⇒ OpenStruct

Parameters:

Returns:

  • (OpenStruct)


53
54
55
56
57
58
59
60
61
# File 'app/models/exported_catalog_item_packet_image_attribute.rb', line 53

def retrieve_images(item)
  images = if profile_mode?
             retrieve_by_profile(item)
           else
             retrieve_by_tag(item)
           end

  OpenStruct.new(all_images: images)
end

#tag_mode?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'app/models/exported_catalog_item_packet_image_attribute.rb', line 47

def tag_mode?
  mode == "tag"
end