Sha256: 2616ed661f00e2adf9d470fb620dc42158eeb3e31ed2fc771e006cdb5ba79b1c

Contents?: true

Size: 477 Bytes

Versions: 8

Compression:

Stored size: 477 Bytes

Contents

module Shamu
  module Attributes

    # Automatically add camelCase aliases for all attributes.
    module CamelCase
      extend ActiveSupport::Concern

      included do |base|
        raise "Must include Shamu::Attributes first." unless base < Shamu::Attributes
      end

      class_methods do
        def attribute( name, *args, **options, &block )
          options[ :as ] ||= name.to_s.camelize( :lower ).to_sym
          super
        end
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
shamu-0.0.24 lib/shamu/attributes/camel_case.rb
shamu-0.0.21 lib/shamu/attributes/camel_case.rb
shamu-0.0.20 lib/shamu/attributes/camel_case.rb
shamu-0.0.19 lib/shamu/attributes/camel_case.rb
shamu-0.0.18 lib/shamu/attributes/camel_case.rb
shamu-0.0.17 lib/shamu/attributes/camel_case.rb
shamu-0.0.15 lib/shamu/attributes/camel_case.rb
shamu-0.0.14 lib/shamu/attributes/camel_case.rb