Class: IronAdmin::Adapters::Http::ModelProxy
- Inherits:
-
Object
- Object
- IronAdmin::Adapters::Http::ModelProxy
- Defined in:
- lib/iron_admin/adapters/http/model_proxy.rb
Overview
Lightweight stand-in for a Ruby model class when a Resource uses
the HTTP adapter. The HTTP adapter pulls fields from the remote
API at request time, so there's no Ruby model to introspect — but
Resource.adapter still needs an object that responds to the
minimal ActiveModel::Naming interface (.model_name.plural,
.model_name.human) so URLs and labels work.
The proxy is built from the resource class name:
IronAdmin::Resources::ExternalCustomerResource →
model_name.plural = "external_customers",
model_name.human = "External customer".
Instance Attribute Summary collapse
-
#resource_class ⇒ Class
readonly
The Resource class this proxy stands in for.
Instance Method Summary collapse
-
#column_names ⇒ Array<String>
HTTP resources have no Ruby-side schema; columns are discovered from the first API response.
-
#initialize(resource_class) ⇒ ModelProxy
constructor
A new instance of ModelProxy.
-
#model_name ⇒ ActiveModel::Name
ActiveModel::Naming-compatible name object derived from the resource class name.
-
#name ⇒ String
(also: #to_s)
Mirror
Class#nameso anything logging the model class doesn't show#<Adapters::Http::ModelProxy:0x...>.
Constructor Details
#initialize(resource_class) ⇒ ModelProxy
Returns a new instance of ModelProxy.
28 29 30 |
# File 'lib/iron_admin/adapters/http/model_proxy.rb', line 28 def initialize(resource_class) @resource_class = resource_class end |
Instance Attribute Details
#resource_class ⇒ Class (readonly)
Returns The Resource class this proxy stands in for.
25 26 27 |
# File 'lib/iron_admin/adapters/http/model_proxy.rb', line 25 def resource_class @resource_class end |
Instance Method Details
#column_names ⇒ Array<String>
HTTP resources have no Ruby-side schema; columns are discovered from the first API response. Return an empty list so any column-introspection checks (e.g. soft-delete detection) decide the column is absent rather than crashing.
46 47 48 |
# File 'lib/iron_admin/adapters/http/model_proxy.rb', line 46 def column_names [] end |
#model_name ⇒ ActiveModel::Name
ActiveModel::Naming-compatible name object derived from the resource class name.
36 37 38 |
# File 'lib/iron_admin/adapters/http/model_proxy.rb', line 36 def model_name @model_name ||= ActiveModel::Name.new(self, nil, demodulized_name) end |
#name ⇒ String Also known as: to_s
Mirror Class#name so anything logging the model class doesn't
show #<Adapters::Http::ModelProxy:0x...>.
54 55 56 |
# File 'lib/iron_admin/adapters/http/model_proxy.rb', line 54 def name demodulized_name end |