Sha256: bc373fb3cb00d515152fc43fbac28e53ef02d932d2f0b0af8f4bca73ece4b7e7
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
require 'active_support/rescuable' require 'rack/response' require 'active_support/json' module JSONAPIonify::Api class Resource extend JSONAPIonify::Autoload autoload_all extend Definitions extend ClassMethods include ErrorHandling include Includer include Builders include Defaults def self.inherited(subclass) super(subclass) subclass.class_eval do context(:api, readonly: true) { self.class.api } context(:resource, readonly: true) { self } end end def self.example_id_generator(&block) define_singleton_method :generate_id, &block end def self.example_instance(index=1) id = generate_id(index) OpenStruct.new.tap do |instance| instance.send "#{id_attribute}=", (id).to_s attributes.select(&:read?).each do |attribute| instance.send "#{attribute.name}=", attribute.example(id, index) end end end example_id_generator { |val| val } def action_name end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jsonapionify-0.9.0 | lib/jsonapionify/api/resource.rb |