Module: CustomMethods
- Included in:
- CloudConnect::Client::Assets::AssetMethods, CloudConnect::Client::Channels::ChannelMethods, CloudConnect::Client::Configurations::ConfigurationMethods, CloudConnect::Client::Fields::FieldMethods, CloudConnect::Client::Messages::MessageMethods, CloudConnect::Client::Tracks::TrackMethods, CloudConnect::Notification::Notification::NotificationMethods
- Defined in:
- lib/cloud_connect/client/custom_methods.rb
Instance Method Summary collapse
-
#apply_to(receiver, client_opts) ⇒ Object
By extending CustomMethods in YourModule, you are able to call YourModule.apply_to(object_or_array) to add YourModule methods to the object or to all objects in the array.
- #extended(base) ⇒ Object
Instance Method Details
#apply_to(receiver, client_opts) ⇒ Object
By extending CustomMethods in YourModule, you are able to call YourModule.apply_to(object_or_array) to add YourModule methods to the object or to all objects in the array.
12 13 14 15 16 17 18 19 |
# File 'lib/cloud_connect/client/custom_methods.rb', line 12 def apply_to(receiver, client_opts) case receiver when Array receiver.each{|a| a.extend self; a._client = client_opts[:client]} when Hashie::Mash receiver.extend self; receiver._client = client_opts[:client] end end |
#extended(base) ⇒ Object
3 4 5 6 |
# File 'lib/cloud_connect/client/custom_methods.rb', line 3 def extended(base) # FIXME: Useless time consuming (especially for arrays)... base.class.send(:attr_accessor, :_client) unless base.respond_to?(:_client) end |