Class: Pod::Specification::DSL::PlatformProxy
- Inherits:
-
Object
- Object
- Pod::Specification::DSL::PlatformProxy
- Defined in:
- lib/cocoapods-core/specification/dsl/platform_proxy.rb
Overview
The PlatformProxy works in conjunction with Specification#_on_platform.
It provides support for a syntax like spec.ios.source_files = 'file'
.
Instance Attribute Summary collapse
-
#platform ⇒ Symbol
readonly
The platform described by this proxy.
-
#spec ⇒ Specification
The specification for this platform proxy.
Instance Method Summary collapse
- #attribute_for_method(method) ⇒ Object private
-
#dependency(*args) ⇒ void
Allows to add dependency for the platform.
-
#deployment_target=(value) ⇒ void
Allows to set the deployment target for the platform.
-
#initialize(spec, platform) ⇒ PlatformProxy
constructor
A new instance of PlatformProxy.
-
#method_missing(meth, *args, &block) ⇒ void
Defines a setter method for each attribute of the specification class, that forwards the message to the #specification using the Specification#on_platform method.
- #respond_to_missing?(method, include_all) ⇒ Boolean private
Constructor Details
#initialize(spec, platform) ⇒ PlatformProxy
Returns a new instance of PlatformProxy.
20 21 22 23 |
# File 'lib/cocoapods-core/specification/dsl/platform_proxy.rb', line 20 def initialize(spec, platform) @spec = spec @platform = platform end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ void
This method returns an undefined value.
Defines a setter method for each attribute of the specification class, that forwards the message to the #specification using the Specification#on_platform method.
31 32 33 34 35 |
# File 'lib/cocoapods-core/specification/dsl/platform_proxy.rb', line 31 def method_missing(meth, *args, &block) return super unless attribute = attribute_for_method(meth) raise NoMethodError, "#{attribute} cannot be set per-platform" unless attribute.multi_platform? spec.store_attribute(attribute.name, args.first, platform) end |
Instance Attribute Details
#platform ⇒ Symbol (readonly)
Returns the platform described by this proxy. Can be either
:ios
or :osx
.
15 16 17 |
# File 'lib/cocoapods-core/specification/dsl/platform_proxy.rb', line 15 def platform @platform end |
#spec ⇒ Specification
Returns the specification for this platform proxy.
10 11 12 |
# File 'lib/cocoapods-core/specification/dsl/platform_proxy.rb', line 10 def spec @spec end |
Instance Method Details
#attribute_for_method(method) ⇒ Object (private)
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/cocoapods-core/specification/dsl/platform_proxy.rb', line 69 def attribute_for_method(method) method = method.to_sym Specification::DSL.attributes.values.find do |attribute| if attribute.writer_name.to_sym == method true elsif attribute.writer_singular_form attribute.writer_singular_form.to_sym == method end end end |
#dependency(*args) ⇒ void
This method returns an undefined value.
Allows to add dependency for the platform.
48 49 50 51 52 53 54 55 |
# File 'lib/cocoapods-core/specification/dsl/platform_proxy.rb', line 48 def dependency(*args) name, *version_requirements = args platform_name = platform.to_s platform_hash = spec.attributes_hash[platform_name] || {} platform_hash['dependencies'] ||= {} platform_hash['dependencies'][name] = version_requirements spec.attributes_hash[platform_name] = platform_hash end |
#deployment_target=(value) ⇒ void
This method returns an undefined value.
Allows to set the deployment target for the platform.
61 62 63 64 65 |
# File 'lib/cocoapods-core/specification/dsl/platform_proxy.rb', line 61 def deployment_target=(value) platform_name = platform.to_s spec.attributes_hash['platforms'] ||= {} spec.attributes_hash['platforms'][platform_name] = value end |
#respond_to_missing?(method, include_all) ⇒ Boolean (private)
39 40 41 42 |
# File 'lib/cocoapods-core/specification/dsl/platform_proxy.rb', line 39 def respond_to_missing?(method, include_all) attribute = attribute_for_method(method) (attribute && attribute.multi_platform?) || super end |