Reputation: 1352
Now I have a function that defined in another ruby file, and I want to call target
and pod
function dynamically. like:
module MyModule
def MyModule.some_function
# do something and then
target "#{result_name}" do
pod 'AFNetworking'
end
end
end
In podfile:
required './some_function'
MyModule.some_function
Is that available?
Edit: Adding Module for my script file, and when I run pod install
and there's an error says unknown method pod in module MyModule
Upvotes: 1
Views: 158
Reputation: 624
You can use define_method :"#{result_name}" do ... end
to do it
For example
# inside foo.rb
def foo
define_method :bar do
puts "bar"
end
end
#inside main.rb
require_relative "foo" # require_relative automatically set ./file
foo
bar # puts "bar"
Upvotes: 1