Module: SellObject

Defined in:
lib/sell_object.rb,
lib/sell_object/buscape.rb,
lib/sell_object/version.rb,
lib/sell_object/shopping_uol.rb,
lib/sell_object/xml_formatter.rb,
lib/sell_object/formatter_proxy.rb,
lib/sell_object/default_mappings.rb,
lib/sell_object/buscape/formatter_proxy.rb,
lib/generators/sell_object/install_generator.rb

Defined Under Namespace

Modules: Buscape, ClassMethods, Config, DefaultMappings, Generators, ShoppingUol, XmlFormatter Classes: FormatterProxy

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



10
11
12
# File 'lib/sell_object.rb', line 10

def self.included(base)
  base.extend ClassMethods
end

.mapping_for(obj, engine) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/sell_object.rb', line 26

def self.mapping_for(obj, engine)
  validate_engine engine
  begin       
    custom_mappings_hash = eval "SellObject::#{obj.class.name}Mappings.#{engine}"
  rescue
    custom_mappings_hash = {}
  end 
  default_mappings_hash = SellObject::DefaultMappings.send engine
  default_mappings_hash.merge custom_mappings_hash
end

.setup {|SellObject::Config| ... } ⇒ Object

Yields:



14
15
16
# File 'lib/sell_object.rb', line 14

def self.setup
  yield SellObject::Config
end

.supported_enginesObject



18
19
20
# File 'lib/sell_object.rb', line 18

def self.supported_engines
  %w(shopping_uol buscape)
end

.validate_engine(engine) ⇒ Object

Raises:

  • (ArgumentError)


22
23
24
# File 'lib/sell_object.rb', line 22

def self.validate_engine(engine)
  raise ArgumentError.new("invalid shopping engine #{engine}") unless supported_engines.include? engine.to_s
end