Sha256: 4be65f17bcc4c239bd467a16b85a013d3e2c789acdd0dac8fe3c08a9c8661644

Contents?: true

Size: 582 Bytes

Versions: 3

Compression:

Stored size: 582 Bytes

Contents

module Dogviz
  module Nominator
    def nominate(names_to_nominees)
      names_to_nominees.each { |name, nominee|
        define_singleton_method sanitized_name(name) do
          nominee
        end
      }
    end

    def nominate_from(nominee_nominator, *nominee_names)
      nominee_names.each { |name|
        accessor_sym = name.to_s.to_sym
        nominate accessor_sym => nominee_nominator.send(accessor_sym)
      }
    end

    private

    def sanitized_name(name)
      return name if name.is_a?(Symbol)
      name.to_s.gsub(/\s/, '_').downcase
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dogviz-0.0.22 lib/dogviz/nominator.rb
dogviz-0.0.21 lib/dogviz/nominator.rb
dogviz-0.0.20 lib/dogviz/nominator.rb