Class: HeyYou::Builder

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/hey_you/builder.rb,
lib/hey_you/builder/push.rb,
lib/hey_you/builder/_base.rb,
lib/hey_you/builder/email.rb

Defined Under Namespace

Classes: Base, DataNotFound, Email, Push, RequiredChannelNotFound, UnknownLocale

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#config

Constructor Details

#initialize(key, **options) ⇒ Builder

Load data from collection yaml via key and interpolate variables. Define methods for each registered channel. After initialize you can use

`instance.<ch_name>`. It will be return instance of HeyYou::Builder::<YOUR_CHANNEL_NAME>

Skip builder for excluded channels (not included in ‘only` option)

Parameters:

  • key (String)
    • notification key for fetching notification data from collection



19
20
21
22
23
24
25
# File 'lib/hey_you/builder.rb', line 19

def initialize(key, **options)
  @data = fetch_from_collection_by_key(key, options[:locale])
  @options = options
  config.registered_channels.each do |ch|
    init_channel_builder(ch, key) if channel_allowed_by_only?(ch, options[:only])
  end
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



10
11
12
# File 'lib/hey_you/builder.rb', line 10

def data
  @data
end

#keysObject (readonly)

Returns the value of attribute keys.



10
11
12
# File 'lib/hey_you/builder.rb', line 10

def keys
  @keys
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/hey_you/builder.rb', line 10

def options
  @options
end