Sha256: 5f9d4a6ddf3ccb2c5acc6b110fddd362f5f39eeb09283dd9be83595017d2dc50

Contents?: true

Size: 943 Bytes

Versions: 11

Compression:

Stored size: 943 Bytes

Contents

module Economic
  class NestedBaseRepo < Economic::BaseRepo
    class << self
      def all(filter_text: "", on:)
        super(filter_text: filter_text, url: nested_endpoint_url(on))
      end

      def filter(filter_text, on:)
        all(filter_text: filter_text, on: on)
      end

      def nested_endpoint_url(model)
        Economic::BaseRepo::URL + nested_endpoint_name(model)
      end

      def nested_endpoint_name(model)
        "#{kebab(model.class.name.demodulize.pluralize)}/#{model.id_key}/#{endpoint_name}"
      end

      def send(model, on:)
        warn "use #{self}.save().  #{self}.send() is deprecated"
        save(model, on: on)
      end

      def save(model, on:)
        super(model, url: nested_endpoint_url(on))
      end

      def find(id, on:)
        super(id, url: nested_endpoint_url(on))
      end

      def destroy(id, on:)
        super(id, url: nested_endpoint_url(on))
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
economic-rest-0.6.3 lib/economic/nested_base_repo.rb
economic-rest-0.6.2 lib/economic/nested_base_repo.rb
economic-rest-0.6.1 lib/economic/nested_base_repo.rb
economic-rest-0.6.0 lib/economic/nested_base_repo.rb
economic-rest-0.5.14 lib/economic/nested_base_repo.rb
economic-rest-0.5.13 lib/economic/nested_base_repo.rb
economic-rest-0.5.12 lib/economic/nested_base_repo.rb
economic-rest-0.5.11 lib/economic/nested_base_repo.rb
economic-rest-0.5.10 lib/economic/nested_base_repo.rb
economic-rest-0.5.9 lib/economic/nested_base_repo.rb
economic-rest-0.5.8 lib/economic/nested_base_repo.rb