Class: Cnf::AbebooksCatalog
- Inherits:
-
Object
- Object
- Cnf::AbebooksCatalog
show all
- Extended by:
- Enumerable, Forwardable
- Defined in:
- lib/cnf/catalog.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.active ⇒ Object
130
131
132
|
# File 'lib/cnf/catalog.rb', line 130
def self.active
select { |catalog| catalog.active }
end
|
.call ⇒ Object
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/cnf/catalog.rb', line 117
def self.call
warn "[DEPRECATION] `call` is deprecated. Please use `find_by_name(name)` instead."
Catalog.new(
marketplace: {
country_code: "US",
currency_code: "USD",
hostname: "www.abebooks.com",
id: "abebooks",
language_code: "en"
}
)
end
|
.data ⇒ Object
106
107
108
109
110
|
# File 'lib/cnf/catalog.rb', line 106
def data
@data ||= Cnf.abebooks_channels.map do |channel|
new(channel.to_h)
end
end
|
.find_by_name(name) ⇒ Object
134
135
136
|
# File 'lib/cnf/catalog.rb', line 134
def self.find_by_name(name)
find { |catalog| catalog.name == name }
end
|
.names ⇒ Object
113
114
115
|
# File 'lib/cnf/catalog.rb', line 113
def self.names
map(&:name)
end
|
Instance Method Details
#borrowable_offer?(offer) ⇒ Boolean
150
151
152
|
# File 'lib/cnf/catalog.rb', line 150
def borrowable_offer?(offer)
matches_any_conditions?(borrowable_offer_conditions, offer)
end
|
#matches_any_conditions?(conditions, offer) ⇒ Boolean
154
155
156
157
158
159
160
|
# File 'lib/cnf/catalog.rb', line 154
def matches_any_conditions?(conditions, offer)
conditions.any? do |hash|
hash.all? do |attribute, value|
offer[attribute.to_sym] == value
end
end
end
|
#supported_parent_offer?(offer) ⇒ Boolean
146
147
148
|
# File 'lib/cnf/catalog.rb', line 146
def supported_parent_offer?(offer)
matches_any_conditions?(parent_offer_conditions, offer)
end
|
#use_competition? ⇒ Boolean
142
143
144
|
# File 'lib/cnf/catalog.rb', line 142
def use_competition?
pricing_method == 'competition'
end
|
#use_flat_rate? ⇒ Boolean
138
139
140
|
# File 'lib/cnf/catalog.rb', line 138
def use_flat_rate?
pricing_method == 'flat_rate'
end
|