Sha256: f67d961f33673457d3d7eb8381a80e73556e2467bd41df500a98fbb3edc28047
Contents?: true
Size: 1.06 KB
Versions: 14
Compression:
Stored size: 1.06 KB
Contents
module JSONAPIonify::Api module Resource::Definitions::Scopes def scope(&block) define_singleton_method(:current_scope) do instance_exec(OpenStruct.new, &block) end context :scope do |context| instance_exec(context, &block) end end alias_method :resource_class, :scope def instance(&block) define_singleton_method(:find_instance) do |id| instance_exec(current_scope, id, OpenStruct.new, &block) end context :instance, persisted: true do |context| instance_exec(context.scope, context.id, context, &block) end end def collection(&block) context :collection do |context| Object.new.instance_exec(context.scope, context, &block) end end def new_instance(&block) define_singleton_method(:build_instance) do Object.new.instance_exec(current_scope, &block) end context :new_instance, persisted: true, readonly: true do |context| Object.new.instance_exec(context.scope, context, &block) end end end end
Version data entries
14 entries across 14 versions & 1 rubygems