Class: Ecoportal::API::V1::PersonSchemas
- Inherits:
-
Object
- Object
- Ecoportal::API::V1::PersonSchemas
- Extended by:
- Common::BaseClass
- Includes:
- Enumerable
- Defined in:
- lib/ecoportal/api/v1/person_schemas.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#client ⇒ Common::Client
readonly
a
Common::Client
object that holds the configuration of the api connection.
Instance Method Summary collapse
-
#each(params: {}) {|schema| ... } ⇒ Enumerable<PersonSchema>
If a
block
is not given it calls Object#to_enum Otherwise it callsget_all
. -
#get_all ⇒ Enumerable<PersonSchema>
Gets all the schemas via api request.
-
#initialize(client) ⇒ Schemas
constructor
An instance object ready to make schema api requests.
Methods included from Common::BaseClass
class_resolver, redef_without_warning, resolve_class
Constructor Details
#initialize(client) ⇒ Schemas
Returns an instance object ready to make schema api requests.
15 16 17 |
# File 'lib/ecoportal/api/v1/person_schemas.rb', line 15 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Common::Client (readonly)
a Common::Client
object that holds the configuration of the api connection.
5 6 7 |
# File 'lib/ecoportal/api/v1/person_schemas.rb', line 5 def client @client end |
Instance Method Details
#each(params: {}) {|schema| ... } ⇒ Enumerable<PersonSchema>
Note:
:params
doesn't really do anything.- same as #get_all but with block :)
to_a
will calleach
(see this detailed explanation)- however, as far as you have an iterator, such as
each
,to_a
should be last resource (see this explanation)
- however, as far as you have an iterator, such as
If a block
is not given it calls Object#to_enum
Otherwise it calls get_all
.
37 38 39 40 |
# File 'lib/ecoportal/api/v1/person_schemas.rb', line 37 def each(params: {}, &block) return to_enum(:each) unless block get_all.each(&block) end |
#get_all ⇒ Enumerable<PersonSchema>
Gets all the schemas via api request.
21 22 23 24 |
# File 'lib/ecoportal/api/v1/person_schemas.rb', line 21 def get_all response = client.get("/person_schemas") Common::WrappedResponse.new(response, person_schema_class) end |