Sha256: 6323fa2cc30aee435b95c503de791f45ecf572f16181962182e9e8cdf3648e0d

Contents?: true

Size: 856 Bytes

Versions: 4

Compression:

Stored size: 856 Bytes

Contents

module Danica
  module VariablesHolder extend ::ActiveSupport::Concern
    require 'danica/variables_holder/variables_builder'

    included do
      class << self
        def variables(*names)
          VariablesBuilder.new(names, self).build
        end

        def variables_names
          @variables_names ||= []
        end
      end
    end

    attr_accessor :variables
 
    def variables=(variables)
      @variables = variables.map { |v| wrap_value(v) }
    end

    def variables
      @variables ||= variables_hash.values
    end
  
    def variables_hash
      @variabels_map ||= (@variables || []).as_hash(self.class.variables_names)
    end

    def variables_value_hash
      variables.map(&:value).as_hash(self.class.variables_names)
    end

    private

    def non_valued_variables
      variables.reject(&:valued?)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
danica-2.2.0 lib/danica/variables_holder.rb
danica-2.1.1 lib/danica/variables_holder.rb
danica-2.1.0 lib/danica/variables_holder.rb
danica-2.0.6 lib/danica/variables_holder.rb