module JsonRepresentations

Constants

QUERY_METHODS
VERSION

Public Class Methods

included(base) click to toggle source
# File lib/json_representations.rb, line 57
def self.included(base)
  base.extend ClassMethods

  base.class_eval do
    eval %{
      def representation(name, options={})
        #{base}.render_representation(self, name.to_sym, options.dup)
      end
    }

    def self.included(base)
      if base.class == Module
        JsonRepresentations.send(:included, base)
        base.instance_variable_set :@parent_entity, self
      else
        context = self
        base.define_singleton_method(:representations) { context.representations }
      end
    end
  end
end