Sha256: ecc0e85dd60a241632e14be188b9f046e0957f374a23c0f11787586ae75ff6c2

Contents?: true

Size: 750 Bytes

Versions: 2

Compression:

Stored size: 750 Bytes

Contents

require 'active_support/concern'

module Landable
  module VariablesConcern
    # includes
    extend ActiveSupport::Concern

    included do
      # attribute definitions
      cattr_accessor :imported_variables do
        {}
      end
    end

    # standard methods

    # custom methods
    module ClassMethods
      def register_landable_variable(variable_name, method_name = nil)
        method_name ||= variable_name

        imported_variables[variable_name] = method_name
      end
    end

    def fetch_landable_variables
      variables = {}

      imported_variables.each do |variable_name, method_name|
        variables[variable_name] = send(method_name)
      end

      variables.with_indifferent_access
    end

    # end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
landable-1.14.0 app/controllers/concerns/landable/variables_concern.rb
landable-1.13.2 app/controllers/concerns/landable/variables_concern.rb