Sha256: f5ea589141cd5e8d61c832d1dc22b0bb1c821fc26a78cbf141a1f7a4ab2ae693

Contents?: true

Size: 688 Bytes

Versions: 1

Compression:

Stored size: 688 Bytes

Contents

require "yaml"

module I18nAttributes
  module GeneratorHelpers

    def generate_yaml_file_data(locale, singular_name, human_name, attributes, orm="active_record", model_i18n_scope="activerecord")
      YAML.dump_stream(
        {
          locale.to_s => {
            model_i18n_scope.to_s => {
              "models" => {
                singular_name => human_name.to_s
              },
              "attributes" => {
                singular_name => columns_hash(attributes)
              }
            }
          }
        }
      )
    end

    private
      def columns_hash(attributes)
        Hash[ attributes.keys.map {|k| [k.to_s, k.to_s.humanize]} ]
      end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
i18n_attributes-0.1.4 lib/i18n_attributes/generator_helpers.rb