Sha256: cd40102b31581e94d00fd2724d33d938a29ab4db50278dcfe0cbf9758d2b2c4c

Contents?: true

Size: 849 Bytes

Versions: 33

Compression:

Stored size: 849 Bytes

Contents

require 'active_support/concern'

# Link relation names seem to have a standard of being dasherized, as they are URIs
# property names, on the other hand should, should be camelcase, lower first
module HalApi::Representer::FormatKeys
  extend ActiveSupport::Concern

  module ClassMethods

    def link(options, &block)
      options = {:rel => options} unless options.is_a?(Hash)
      options[:rel] = options[:rel].to_s.dasherize
      super(options, &block)
    end

    def property(name, options={})
      n = (options[:as] || name).to_s
      options[:as] = options[:embedded] ? n.dasherize : n.camelize(:lower)
      super(name, options)
    end

    def collection(name, options={})
      n = (options[:as] || name).to_s
      options[:as] = options[:embedded] ? n.dasherize : n.camelize(:lower)
      super(name, options)
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
hal_api-rails-1.2.2 lib/hal_api/representer/format_keys.rb
hal_api-rails-1.2.1 lib/hal_api/representer/format_keys.rb
hal_api-rails-1.2.0 lib/hal_api/representer/format_keys.rb
hal_api-rails-1.1.5 lib/hal_api/representer/format_keys.rb
hal_api-rails-1.1.4 lib/hal_api/representer/format_keys.rb
hal_api-rails-0.3.7 lib/hal_api/representer/format_keys.rb
hal_api-rails-0.3.6 lib/hal_api/representer/format_keys.rb
hal_api-rails-1.1.3 lib/hal_api/representer/format_keys.rb
hal_api-rails-0.3.5 lib/hal_api/representer/format_keys.rb
hal_api-rails-1.1.2 lib/hal_api/representer/format_keys.rb
hal_api-rails-1.1.1 lib/hal_api/representer/format_keys.rb
hal_api-rails-1.1.0 lib/hal_api/representer/format_keys.rb
hal_api-rails-1.0.0 lib/hal_api/representer/format_keys.rb
hal_api-rails-0.7.0 lib/hal_api/representer/format_keys.rb
hal_api-rails-0.6.0 lib/hal_api/representer/format_keys.rb
hal_api-rails-0.5.0 lib/hal_api/representer/format_keys.rb
hal_api-rails-0.4.1 lib/hal_api/representer/format_keys.rb
hal_api-rails-0.4.0 lib/hal_api/representer/format_keys.rb
hal_api-rails-0.3.4 lib/hal_api/representer/format_keys.rb
hal_api-rails-0.3.3 lib/hal_api/representer/format_keys.rb