Module: Manufacturable::Item

Defined in:
lib/manufacturable/item.rb

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



25
26
27
# File 'lib/manufacturable/item.rb', line 25

def self.extended(base)
  base.include(InstanceMethods)
end

Instance Method Details

#corresponds_to(key, type = self.superclass) ⇒ Object



12
13
14
15
# File 'lib/manufacturable/item.rb', line 12

def corresponds_to(key, type = self.superclass)
  key = key == type ? Registrar::ALL_KEY : key
  Registrar.register(type, key, self)
end

#corresponds_to_all(type = self.superclass) ⇒ Object



17
18
19
# File 'lib/manufacturable/item.rb', line 17

def corresponds_to_all(type = self.superclass)
  corresponds_to(Registrar::ALL_KEY, type)
end

#default_manufacturable(type = self.superclass) ⇒ Object



21
22
23
# File 'lib/manufacturable/item.rb', line 21

def default_manufacturable(type = self.superclass)
  corresponds_to(Registrar::DEFAULT_KEY, type)
end

#new(*args, **kwargs, &block) ⇒ Object



5
6
7
8
9
10
# File 'lib/manufacturable/item.rb', line 5

def new(*args, **kwargs, &block)
  key = kwargs.delete(:manufacturable_item_key)
  instance = kwargs.empty? ? super(*args, &block) : super
  instance.instance_variable_set(:@manufacturable_item_key, key)
  instance
end