class Frodo::EntitySet

This class represents a set of entities within an Frodo service. It is instantiated whenever an Frodo::Service is asked for an EntitySet via the Frodo::Service#[] method call. It also provides Enumerable behavior so that you can interact with the entities within a set in a very comfortable way.

This class also implements a query interface for finding certain entities based on query criteria or limiting the result set returned by the set. This functionality is implemented through transparent proxy objects.

Attributes

container[R]

The EntitySet's container name

name[R]

The name of the EntitySet

namespace[R]

The Frodo::Service's namespace

service_name[R]

The Frodo::Service's identifiable name

type[R]

The Entity type for the EntitySet

Public Class Methods

new(options = {}) click to toggle source

Sets up the EntitySet to permit querying for the resources in the set.

@param options [Hash] the options to setup the EntitySet @return [Frodo::EntitySet] an instance of the EntitySet

# File lib/frodo/entity_set.rb, line 28
def initialize(options = {})
  @name         = options[:name]
  @type         = options[:type]
  @namespace    = options[:namespace]
  @service_name = options[:service_name]
  @container    = options[:container]
end

Public Instance Methods

entity_options() click to toggle source

Options used for instantiating a new Frodo::Entity for this set. @return [Hash] @api private

# File lib/frodo/entity_set.rb, line 122
def entity_options
  {
    service_name: service_name,
    type:         type,
    entity_set:   self
  }
end
entity_primary_key() click to toggle source
# File lib/frodo/entity_set.rb, line 74
def entity_primary_key()
  new_entity.primary_key
end
new_entity(properties = {}) click to toggle source

Create a new Entity for this set with the given properties. @param properties [Hash] property name as key and it's initial value @return [Frodo::Entity]

# File lib/frodo/entity_set.rb, line 62
def new_entity(properties = {})
  Frodo::Entity.with_properties(properties, entity_options)
end
query(options = {}) click to toggle source

Returns a query targetted at the current EntitySet. @param options [Hash] query options @return [Frodo::Query]

# File lib/frodo/entity_set.rb, line 69
def query(options = {})
  Frodo::Query.new(self, options)
end
service() click to toggle source

The Frodo::Service this EntitySet is associated with. @return [Frodo::Service] @api private

# File lib/frodo/entity_set.rb, line 115
def service
  @service ||= Frodo::ServiceRegistry[service_name]
end