Module: RailsPipeline::Emitter::ClassMethods
- Defined in:
- lib/rails-pipeline/emitter.rb
Instance Method Summary collapse
- #_secret ⇒ Object
-
#major(version) ⇒ Object
Get the major version number from a “1_1” style major/minor version string.
- #pipeline_method_cache ⇒ Object
- #pipeline_method_cache=(cache) ⇒ Object
-
#pipeline_versions ⇒ Object
Get the list of versions to emit (all that are implemented, basically).
-
#topic_name(version = "1_0") ⇒ Object
Get pub/sub topic name to which changes to this model will be published.
Instance Method Details
#_secret ⇒ Object
99 100 101 |
# File 'lib/rails-pipeline/emitter.rb', line 99 def _secret ENV.fetch("PIPELINE_SECRET", Rails.application.config.secret_token) end |
#major(version) ⇒ Object
Get the major version number from a “1_1” style major/minor version string
90 91 92 93 94 95 96 97 |
# File 'lib/rails-pipeline/emitter.rb', line 90 def major(version) if version.include? '_' major, _ = version.split('_', 2) else major = version end return major end |
#pipeline_method_cache ⇒ Object
103 104 105 |
# File 'lib/rails-pipeline/emitter.rb', line 103 def pipeline_method_cache @pipeline_method_cache ||= {} end |
#pipeline_method_cache=(cache) ⇒ Object
107 108 109 |
# File 'lib/rails-pipeline/emitter.rb', line 107 def pipeline_method_cache=(cache) @pipeline_method_cache = cache end |
#pipeline_versions ⇒ Object
Get the list of versions to emit (all that are implemented, basically)
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/rails-pipeline/emitter.rb', line 65 def pipeline_versions if pipeline_method_cache.any? return pipeline_method_cache.keys end versions = [] pipeline_methods = instance_methods.grep(/^to_pipeline/).sort pipeline_methods.each do |pipeline_method| version = pipeline_method.to_s.gsub("to_pipeline_", "") if version.starts_with?("1_") && version != "1_0" # Delete the default v1.0 emitter if a later v1 emitter is defined i = versions.index("1_0") versions.delete_at(i) if !i.nil? end pipeline_method_cache[version] = pipeline_method versions << version end return versions end |
#topic_name(version = "1_0") ⇒ Object
Get pub/sub topic name to which changes to this model will be published
85 86 87 |
# File 'lib/rails-pipeline/emitter.rb', line 85 def topic_name(version="1_0") return "harrys-#{Rails.env}-v#{major(version)}-#{table_name}" end |