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
132
133
134
|
# File 'lib/cnf/catalog.rb', line 132
def self.active
select { |catalog| catalog.active }
end
|
.call ⇒ Object
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/cnf/catalog.rb', line 119
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
108
109
110
111
112
|
# File 'lib/cnf/catalog.rb', line 108
def data
@data ||= Cnf.abebooks_channels.map do |channel|
new(channel.to_h)
end
end
|
.find_by_name(name) ⇒ Object
136
137
138
|
# File 'lib/cnf/catalog.rb', line 136
def self.find_by_name(name)
find { |catalog| catalog.name == name }
end
|
.names ⇒ Object
115
116
117
|
# File 'lib/cnf/catalog.rb', line 115
def self.names
map(&:name)
end
|
Instance Method Details
#borrowable_offer?(offer) ⇒ Boolean
152
153
154
|
# File 'lib/cnf/catalog.rb', line 152
def borrowable_offer?(offer)
matches_any_conditions?(borrowable_offer_conditions, offer)
end
|
#matches_any_conditions?(conditions, offer) ⇒ Boolean
156
157
158
159
160
161
162
|
# File 'lib/cnf/catalog.rb', line 156
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
148
149
150
|
# File 'lib/cnf/catalog.rb', line 148
def supported_parent_offer?(offer)
matches_any_conditions?(parent_offer_conditions, offer)
end
|
#use_competition? ⇒ Boolean
144
145
146
|
# File 'lib/cnf/catalog.rb', line 144
def use_competition?
pricing_method == 'competition'
end
|
#use_flat_rate? ⇒ Boolean
140
141
142
|
# File 'lib/cnf/catalog.rb', line 140
def use_flat_rate?
pricing_method == 'flat_rate'
end
|