Class: Collavre::Integration
- Inherits:
-
Object
- Object
- Collavre::Integration
- Defined in:
- lib/collavre/integration_registry.rb
Overview
Represents a registered integration
Instance Attribute Summary collapse
-
#creative_menu_partial ⇒ Object
readonly
Returns the value of attribute creative_menu_partial.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#enabled_for ⇒ Object
readonly
Returns the value of attribute enabled_for.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
-
#settings_partial ⇒ Object
readonly
Returns the value of attribute settings_partial.
Instance Method Summary collapse
-
#enabled_for?(creative) ⇒ Boolean
Check if this integration is enabled for a specific creative.
-
#initialize(name, config) ⇒ Integration
constructor
A new instance of Integration.
-
#path_for(method_name, **args) ⇒ Object
Generate a path using the integration’s routes.
Constructor Details
#initialize(name, config) ⇒ Integration
Returns a new instance of Integration.
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/collavre/integration_registry.rb', line 96 def initialize(name, config) @name = name.to_sym @label = config[:label] || name.to_s.titleize @icon = config[:icon] @description = config[:description] @routes = config[:routes] @creative_menu_partial = config[:creative_menu_partial] @settings_partial = config[:settings_partial] @enabled_for = config[:enabled_for] || ->(_creative) { true } validate! end |
Instance Attribute Details
#creative_menu_partial ⇒ Object (readonly)
Returns the value of attribute creative_menu_partial.
93 94 95 |
# File 'lib/collavre/integration_registry.rb', line 93 def @creative_menu_partial end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
93 94 95 |
# File 'lib/collavre/integration_registry.rb', line 93 def description @description end |
#enabled_for ⇒ Object (readonly)
Returns the value of attribute enabled_for.
93 94 95 |
# File 'lib/collavre/integration_registry.rb', line 93 def enabled_for @enabled_for end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
93 94 95 |
# File 'lib/collavre/integration_registry.rb', line 93 def icon @icon end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
93 94 95 |
# File 'lib/collavre/integration_registry.rb', line 93 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
93 94 95 |
# File 'lib/collavre/integration_registry.rb', line 93 def name @name end |
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
93 94 95 |
# File 'lib/collavre/integration_registry.rb', line 93 def routes @routes end |
#settings_partial ⇒ Object (readonly)
Returns the value of attribute settings_partial.
93 94 95 |
# File 'lib/collavre/integration_registry.rb', line 93 def settings_partial @settings_partial end |
Instance Method Details
#enabled_for?(creative) ⇒ Boolean
Check if this integration is enabled for a specific creative
110 111 112 113 |
# File 'lib/collavre/integration_registry.rb', line 110 def enabled_for?(creative) return true unless @enabled_for.respond_to?(:call) @enabled_for.call(creative) end |
#path_for(method_name, **args) ⇒ Object
Generate a path using the integration’s routes
116 117 118 119 120 |
# File 'lib/collavre/integration_registry.rb', line 116 def path_for(method_name, **args) return nil unless @routes return nil unless @routes.respond_to?(method_name) @routes.public_send(method_name, **args) end |