Method: Xcode::Resource#initialize

Defined in:
lib/xcode/resource.rb

#initialize(identifier, registry) ⇒ Resource

A Resource is created during Project#initialize, when the project is first parsed. Afterwards each Resource is usually generated through the special getter method defined through #define_property.

Parameters:

  • identifier (String)

    the unique identifier for this resource.

  • registry (Registry)

    the core registry for the system.

See Also:



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/xcode/resource.rb', line 180

def initialize identifier, registry
  @registry = registry
  @properties = {}
  @identifier = identifier
  
  # Create property methods for all of the key-value pairs found in the
  # registry for specified identifier.
  
  Array(registry.properties(@identifier)).each do |key,value| 
    send :define_property, key, value
  end
  
  #  
  # Based on the `isa` property find if there are constants within
  # the Xcode module that matches and if it does, then we want to 
  # automatically include those modules into the Resource object.
  # 
  constants = Registry.isa_to_module(isa)
  
  constants.each do |constant|
    self.extend(constant) if constant
  end
  
end