Sha256: 722d3980b47e66ed86554927de3c1289f2c48bf8b5c3cd67944417ac1696e64e

Contents?: true

Size: 784 Bytes

Versions: 16

Compression:

Stored size: 784 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

16 entries across 16 versions & 1 rubygems

Version Path
landable-1.13.1 app/controllers/concerns/landable/variables_concern.rb
landable-1.12.3 app/controllers/concerns/landable/variables_concern.rb
landable-1.12.2 app/controllers/concerns/landable/variables_concern.rb
landable-1.12.1 app/controllers/concerns/landable/variables_concern.rb
landable-1.11.1 app/controllers/concerns/landable/variables_concern.rb
landable-1.11.0 app/controllers/concerns/landable/variables_concern.rb
landable-1.10.0.rc2 app/controllers/concerns/landable/variables_concern.rb
landable-1.10.0.rc1 app/controllers/concerns/landable/variables_concern.rb
landable-1.9.2 app/controllers/concerns/landable/variables_concern.rb
landable-1.9.1 app/controllers/concerns/landable/variables_concern.rb
landable-1.9.0 app/controllers/concerns/landable/variables_concern.rb
landable-1.9.0.rc2 app/controllers/concerns/landable/variables_concern.rb
landable-1.9.0.rc1 app/controllers/concerns/landable/variables_concern.rb
landable-1.8.0 app/controllers/concerns/landable/variables_concern.rb
landable-1.7.1.rc1 app/controllers/concerns/landable/variables_concern.rb
landable-1.7.0 app/controllers/concerns/landable/variables_concern.rb