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 Schedulable

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 Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#image_sourceObject (readonly)



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

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

#modeObject (readonly)



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

validates :mode, inclusion: { in: MODES }

Instance Method Details

#exported_catalog_item_packetExportedCatalogItemPacket



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

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

#profile_mode?Boolean

Returns:

  • (Boolean)


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

def profile_mode?
  mode == "profile"
end

#retrieve_images(item) ⇒ Object



46
47
48
49
50
51
52
53
54
# File 'app/models/exported_catalog_item_packet_image_attribute.rb', line 46

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)


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

def tag_mode?
  mode == "tag"
end