aws-sdk 1.8.5 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.yardopts +1 -0
- data/README.rdoc +8 -0
- data/lib/aws-sdk.rb +39 -35
- data/lib/aws/api_config/CloudFront-2012-07-01.yml +2398 -0
- data/lib/aws/api_config/DirectConnect-2012-10-25.yml +475 -0
- data/lib/aws/api_config/DynamoDB-2011-12-05.yml +8 -0
- data/lib/aws/api_config/DynamoDB-2012-08-10.yml +1516 -0
- data/lib/aws/api_config/OpsWorks-2013-02-18.yml +2 -2
- data/lib/aws/auto_scaling.rb +44 -44
- data/lib/aws/auto_scaling/activity.rb +1 -1
- data/lib/aws/auto_scaling/activity_collection.rb +14 -15
- data/lib/aws/auto_scaling/client.rb +277 -277
- data/lib/aws/auto_scaling/config.rb +1 -1
- data/lib/aws/auto_scaling/group.rb +35 -36
- data/lib/aws/auto_scaling/group_collection.rb +10 -10
- data/lib/aws/auto_scaling/group_options.rb +19 -19
- data/lib/aws/auto_scaling/instance.rb +27 -27
- data/lib/aws/auto_scaling/instance_collection.rb +10 -10
- data/lib/aws/auto_scaling/launch_configuration.rb +3 -3
- data/lib/aws/auto_scaling/launch_configuration_collection.rb +1 -1
- data/lib/aws/auto_scaling/notification_configuration.rb +2 -2
- data/lib/aws/auto_scaling/notification_configuration_collection.rb +37 -38
- data/lib/aws/auto_scaling/scaling_policy.rb +3 -3
- data/lib/aws/auto_scaling/scaling_policy_collection.rb +6 -6
- data/lib/aws/auto_scaling/scaling_policy_options.rb +8 -7
- data/lib/aws/auto_scaling/scheduled_action.rb +3 -3
- data/lib/aws/auto_scaling/scheduled_action_collection.rb +28 -28
- data/lib/aws/auto_scaling/tag_collection.rb +30 -28
- data/lib/aws/cloud_formation.rb +95 -94
- data/lib/aws/cloud_formation/client.rb +136 -133
- data/lib/aws/cloud_formation/config.rb +1 -1
- data/lib/aws/cloud_formation/stack.rb +37 -37
- data/lib/aws/cloud_formation/stack_collection.rb +28 -27
- data/lib/aws/cloud_formation/stack_event.rb +9 -11
- data/lib/aws/cloud_formation/stack_output.rb +1 -1
- data/lib/aws/cloud_formation/stack_resource.rb +6 -6
- data/lib/aws/cloud_formation/stack_resource_collection.rb +11 -12
- data/lib/aws/cloud_formation/stack_resource_summary_collection.rb +11 -11
- data/lib/aws/cloud_formation/stack_summary_collection.rb +39 -39
- data/lib/aws/cloud_front.rb +21 -21
- data/lib/aws/cloud_front/client.rb +853 -652
- data/lib/aws/cloud_front/request.rb +3 -0
- data/lib/aws/cloud_search.rb +22 -22
- data/lib/aws/cloud_search/client.rb +322 -315
- data/lib/aws/cloud_search/config.rb +1 -1
- data/lib/aws/cloud_watch.rb +39 -39
- data/lib/aws/cloud_watch/alarm.rb +55 -37
- data/lib/aws/cloud_watch/alarm_collection.rb +18 -18
- data/lib/aws/cloud_watch/alarm_history_item_collection.rb +2 -2
- data/lib/aws/cloud_watch/client.rb +360 -146
- data/lib/aws/cloud_watch/config.rb +1 -1
- data/lib/aws/cloud_watch/metric.rb +15 -15
- data/lib/aws/cloud_watch/metric_alarm_collection.rb +17 -17
- data/lib/aws/cloud_watch/metric_collection.rb +16 -16
- data/lib/aws/cloud_watch/metric_statistics.rb +11 -11
- data/lib/aws/core.rb +243 -225
- data/lib/aws/core/async_handle.rb +13 -13
- data/lib/aws/core/cacheable.rb +14 -15
- data/lib/aws/core/client.rb +40 -15
- data/lib/aws/core/collection.rb +42 -46
- data/lib/aws/core/collection/with_limit_and_next_token.rb +1 -1
- data/lib/aws/core/collection/with_next_token.rb +1 -1
- data/lib/aws/core/configuration.rb +97 -133
- data/lib/aws/core/credential_providers.rb +16 -16
- data/lib/aws/core/data.rb +23 -23
- data/lib/aws/core/http/connection_pool.rb +348 -0
- data/lib/aws/core/http/net_http_handler.rb +17 -26
- data/lib/aws/core/http/patch.rb +102 -0
- data/lib/aws/core/http/request.rb +13 -19
- data/lib/aws/core/http/response.rb +2 -2
- data/lib/aws/core/lazy_error_classes.rb +17 -17
- data/lib/aws/core/log_formatter.rb +70 -104
- data/lib/aws/core/options/json_serializer.rb +1 -1
- data/lib/aws/core/options/validator.rb +4 -4
- data/lib/aws/core/page_result.rb +8 -8
- data/lib/aws/core/policy.rb +49 -49
- data/lib/aws/core/region.rb +72 -0
- data/lib/aws/core/region_collection.rb +106 -0
- data/lib/aws/core/resource.rb +5 -5
- data/lib/aws/core/response.rb +20 -17
- data/lib/aws/core/rest_request_builder.rb +4 -4
- data/lib/aws/core/service_interface.rb +24 -2
- data/lib/aws/core/signature/version_3.rb +2 -2
- data/lib/aws/core/uri_escape.rb +1 -1
- data/lib/aws/core/xml/frame_stack.rb +1 -1
- data/lib/aws/core/xml/grammar.rb +3 -4
- data/lib/aws/core/xml/sax_handlers/libxml.rb +2 -2
- data/lib/aws/core/xml/sax_handlers/nokogiri.rb +3 -3
- data/lib/aws/core/xml/sax_handlers/rexml.rb +5 -5
- data/lib/aws/core/xml/stub.rb +9 -9
- data/lib/aws/data_pipeline.rb +21 -21
- data/lib/aws/data_pipeline/client.rb +189 -133
- data/lib/aws/data_pipeline/config.rb +1 -1
- data/lib/aws/direct_connect.rb +74 -0
- data/lib/aws/direct_connect/client.rb +253 -0
- data/lib/aws/direct_connect/config.rb +18 -0
- data/lib/aws/direct_connect/errors.rb +22 -0
- data/lib/aws/direct_connect/request.rb +27 -0
- data/lib/aws/dynamo_db.rb +71 -69
- data/lib/aws/dynamo_db/attribute_collection.rb +53 -58
- data/lib/aws/dynamo_db/batch_get.rb +23 -23
- data/lib/aws/dynamo_db/batch_write.rb +43 -43
- data/lib/aws/dynamo_db/binary.rb +9 -9
- data/lib/aws/dynamo_db/client.rb +494 -509
- data/lib/aws/dynamo_db/client_base.rb +91 -0
- data/lib/aws/dynamo_db/client_v2.rb +825 -0
- data/lib/aws/dynamo_db/config.rb +1 -1
- data/lib/aws/dynamo_db/item.rb +10 -10
- data/lib/aws/dynamo_db/item_collection.rb +75 -75
- data/lib/aws/dynamo_db/table.rb +85 -85
- data/lib/aws/dynamo_db/table_collection.rb +13 -13
- data/lib/aws/ec2.rb +132 -142
- data/lib/aws/ec2/attachment.rb +31 -36
- data/lib/aws/ec2/attachment_collection.rb +1 -1
- data/lib/aws/ec2/availability_zone.rb +4 -4
- data/lib/aws/ec2/client.rb +2272 -2125
- data/lib/aws/ec2/config.rb +1 -1
- data/lib/aws/ec2/customer_gateway.rb +6 -6
- data/lib/aws/ec2/customer_gateway_collection.rb +6 -6
- data/lib/aws/ec2/dhcp_options.rb +3 -3
- data/lib/aws/ec2/dhcp_options_collection.rb +10 -10
- data/lib/aws/ec2/elastic_ip.rb +15 -15
- data/lib/aws/ec2/elastic_ip_collection.rb +11 -15
- data/lib/aws/ec2/export_task.rb +4 -4
- data/lib/aws/ec2/export_task_collection.rb +11 -11
- data/lib/aws/ec2/filtered_collection.rb +6 -8
- data/lib/aws/ec2/image.rb +46 -40
- data/lib/aws/ec2/image_collection.rb +44 -52
- data/lib/aws/ec2/instance.rb +64 -62
- data/lib/aws/ec2/instance_collection.rb +47 -50
- data/lib/aws/ec2/internet_gateway.rb +6 -6
- data/lib/aws/ec2/internet_gateway/attachment.rb +13 -13
- data/lib/aws/ec2/internet_gateway_collection.rb +3 -3
- data/lib/aws/ec2/key_pair.rb +3 -3
- data/lib/aws/ec2/key_pair_collection.rb +12 -12
- data/lib/aws/ec2/network_acl.rb +39 -39
- data/lib/aws/ec2/network_acl/association.rb +2 -2
- data/lib/aws/ec2/network_acl/entry.rb +22 -22
- data/lib/aws/ec2/network_acl_collection.rb +2 -2
- data/lib/aws/ec2/network_interface.rb +13 -4
- data/lib/aws/ec2/network_interface/attachment.rb +3 -3
- data/lib/aws/ec2/network_interface_collection.rb +5 -5
- data/lib/aws/ec2/permission_collection.rb +1 -1
- data/lib/aws/ec2/region.rb +6 -6
- data/lib/aws/ec2/region_collection.rb +1 -1
- data/lib/aws/ec2/reserved_instances_collection.rb +2 -2
- data/lib/aws/ec2/reserved_instances_offering_collection.rb +2 -2
- data/lib/aws/ec2/resource_tag_collection.rb +5 -5
- data/lib/aws/ec2/route_table.rb +14 -14
- data/lib/aws/ec2/route_table/association.rb +22 -22
- data/lib/aws/ec2/route_table/route.rb +8 -8
- data/lib/aws/ec2/route_table_collection.rb +3 -3
- data/lib/aws/ec2/security_group.rb +39 -41
- data/lib/aws/ec2/security_group_collection.rb +19 -21
- data/lib/aws/ec2/snapshot.rb +3 -3
- data/lib/aws/ec2/snapshot_collection.rb +11 -12
- data/lib/aws/ec2/subnet.rb +2 -2
- data/lib/aws/ec2/subnet_collection.rb +17 -17
- data/lib/aws/ec2/tag_collection.rb +1 -1
- data/lib/aws/ec2/tagged_collection.rb +7 -7
- data/lib/aws/ec2/tagged_item.rb +10 -10
- data/lib/aws/ec2/volume.rb +16 -16
- data/lib/aws/ec2/volume_collection.rb +9 -12
- data/lib/aws/ec2/vpc.rb +6 -6
- data/lib/aws/ec2/vpc_collection.rb +10 -10
- data/lib/aws/ec2/vpn_connection.rb +4 -4
- data/lib/aws/ec2/vpn_connection/telemetry.rb +1 -1
- data/lib/aws/ec2/vpn_connection_collection.rb +6 -6
- data/lib/aws/ec2/vpn_gateway.rb +2 -2
- data/lib/aws/ec2/vpn_gateway_collection.rb +5 -5
- data/lib/aws/elastic_beanstalk.rb +12 -12
- data/lib/aws/elastic_beanstalk/client.rb +376 -368
- data/lib/aws/elastic_beanstalk/config.rb +1 -1
- data/lib/aws/elastic_transcoder.rb +5 -5
- data/lib/aws/elastic_transcoder/client.rb +283 -283
- data/lib/aws/elastic_transcoder/config.rb +1 -1
- data/lib/aws/elasticache.rb +12 -12
- data/lib/aws/elasticache/client.rb +484 -479
- data/lib/aws/elasticache/config.rb +1 -1
- data/lib/aws/elb.rb +23 -23
- data/lib/aws/elb/availability_zone_collection.rb +34 -34
- data/lib/aws/elb/backend_server_policy_collection.rb +24 -24
- data/lib/aws/elb/client.rb +153 -153
- data/lib/aws/elb/config.rb +1 -1
- data/lib/aws/elb/errors.rb +1 -1
- data/lib/aws/elb/instance_collection.rb +20 -25
- data/lib/aws/elb/listener.rb +3 -3
- data/lib/aws/elb/listener_collection.rb +8 -8
- data/lib/aws/elb/load_balancer.rb +15 -16
- data/lib/aws/elb/load_balancer_collection.rb +36 -24
- data/lib/aws/elb/load_balancer_policy.rb +1 -1
- data/lib/aws/elb/load_balancer_policy_collection.rb +5 -5
- data/lib/aws/emr.rb +28 -26
- data/lib/aws/emr/client.rb +165 -149
- data/lib/aws/emr/config.rb +1 -1
- data/lib/aws/emr/instance_group.rb +1 -1
- data/lib/aws/emr/instance_group_collection.rb +1 -1
- data/lib/aws/emr/job_flow.rb +27 -26
- data/lib/aws/emr/job_flow_collection.rb +34 -34
- data/lib/aws/errors.rb +7 -7
- data/lib/aws/glacier.rb +21 -21
- data/lib/aws/glacier/archive_collection.rb +2 -2
- data/lib/aws/glacier/client.rb +139 -140
- data/lib/aws/glacier/config.rb +1 -1
- data/lib/aws/glacier/vault.rb +2 -2
- data/lib/aws/glacier/vault_collection.rb +1 -1
- data/lib/aws/iam.rb +133 -144
- data/lib/aws/iam/access_key.rb +17 -17
- data/lib/aws/iam/access_key_collection.rb +22 -22
- data/lib/aws/iam/account_alias_collection.rb +2 -2
- data/lib/aws/iam/client.rb +429 -420
- data/lib/aws/iam/collection.rb +1 -1
- data/lib/aws/iam/config.rb +2 -2
- data/lib/aws/iam/group.rb +8 -8
- data/lib/aws/iam/group_collection.rb +16 -16
- data/lib/aws/iam/group_policy_collection.rb +6 -6
- data/lib/aws/iam/group_user_collection.rb +3 -3
- data/lib/aws/iam/mfa_device.rb +1 -1
- data/lib/aws/iam/mfa_device_collection.rb +9 -9
- data/lib/aws/iam/policy_collection.rb +4 -4
- data/lib/aws/iam/resource.rb +2 -2
- data/lib/aws/iam/server_certificate.rb +1 -1
- data/lib/aws/iam/server_certificate_collection.rb +15 -15
- data/lib/aws/iam/signing_certificate.rb +29 -29
- data/lib/aws/iam/signing_certificate_collection.rb +23 -23
- data/lib/aws/iam/user.rb +33 -38
- data/lib/aws/iam/user_collection.rb +27 -27
- data/lib/aws/iam/user_group_collection.rb +3 -3
- data/lib/aws/iam/user_policy_collection.rb +6 -6
- data/lib/aws/iam/virtual_mfa_device.rb +12 -12
- data/lib/aws/iam/virtual_mfa_device_collection.rb +4 -4
- data/lib/aws/import_export.rb +22 -21
- data/lib/aws/import_export/client.rb +47 -43
- data/lib/aws/ops_works.rb +5 -5
- data/lib/aws/ops_works/client.rb +484 -438
- data/lib/aws/ops_works/config.rb +1 -1
- data/lib/aws/rails.rb +34 -34
- data/lib/aws/rds.rb +18 -18
- data/lib/aws/rds/client.rb +1286 -1277
- data/lib/aws/rds/config.rb +1 -1
- data/lib/aws/rds/db_instance.rb +15 -4
- data/lib/aws/rds/db_snapshot.rb +1 -1
- data/lib/aws/record.rb +50 -24
- data/lib/aws/record/abstract_base.rb +52 -60
- data/lib/aws/record/attributes.rb +79 -79
- data/lib/aws/record/conversion.rb +1 -1
- data/lib/aws/record/dirty_tracking.rb +69 -67
- data/lib/aws/record/errors.rb +21 -21
- data/lib/aws/record/exceptions.rb +2 -2
- data/lib/aws/record/hash_model.rb +20 -21
- data/lib/aws/record/hash_model/attributes.rb +13 -15
- data/lib/aws/record/hash_model/finder_methods.rb +46 -46
- data/lib/aws/record/hash_model/scope.rb +31 -31
- data/lib/aws/record/model.rb +136 -136
- data/lib/aws/record/model/attributes.rb +57 -59
- data/lib/aws/record/model/finder_methods.rb +67 -67
- data/lib/aws/record/model/scope.rb +48 -49
- data/lib/aws/record/naming.rb +1 -1
- data/lib/aws/record/scope.rb +23 -19
- data/lib/aws/record/validations.rb +253 -271
- data/lib/aws/record/validator.rb +3 -3
- data/lib/aws/record/validators/acceptance.rb +1 -3
- data/lib/aws/record/validators/block.rb +1 -3
- data/lib/aws/record/validators/confirmation.rb +1 -3
- data/lib/aws/record/validators/count.rb +2 -4
- data/lib/aws/record/validators/exclusion.rb +2 -4
- data/lib/aws/record/validators/format.rb +2 -4
- data/lib/aws/record/validators/inclusion.rb +1 -3
- data/lib/aws/record/validators/length.rb +5 -7
- data/lib/aws/record/validators/method.rb +1 -3
- data/lib/aws/record/validators/numericality.rb +6 -8
- data/lib/aws/record/validators/presence.rb +1 -3
- data/lib/aws/redshift.rb +14 -14
- data/lib/aws/redshift/client.rb +596 -592
- data/lib/aws/redshift/config.rb +1 -1
- data/lib/aws/route_53.rb +30 -30
- data/lib/aws/route_53/change_batch.rb +7 -7
- data/lib/aws/route_53/client.rb +188 -152
- data/lib/aws/route_53/hosted_zone.rb +4 -4
- data/lib/aws/route_53/hosted_zone_collection.rb +7 -7
- data/lib/aws/route_53/resource_record_set.rb +10 -10
- data/lib/aws/route_53/resource_record_set_collection.rb +6 -6
- data/lib/aws/s3.rb +79 -79
- data/lib/aws/s3/access_control_list.rb +44 -36
- data/lib/aws/s3/acl_options.rb +51 -51
- data/lib/aws/s3/bucket.rb +146 -146
- data/lib/aws/s3/bucket_collection.rb +21 -21
- data/lib/aws/s3/bucket_lifecycle_configuration.rb +81 -82
- data/lib/aws/s3/bucket_tag_collection.rb +4 -2
- data/lib/aws/s3/cipher_io.rb +5 -4
- data/lib/aws/s3/client.rb +89 -84
- data/lib/aws/s3/client/xml.rb +1 -1
- data/lib/aws/s3/config.rb +7 -1
- data/lib/aws/s3/cors_rule.rb +2 -0
- data/lib/aws/s3/cors_rule_collection.rb +42 -40
- data/lib/aws/s3/data_options.rb +16 -11
- data/lib/aws/s3/encryption_utils.rb +2 -2
- data/lib/aws/s3/errors.rb +7 -7
- data/lib/aws/s3/multipart_upload.rb +30 -33
- data/lib/aws/s3/multipart_upload_collection.rb +8 -6
- data/lib/aws/s3/object_collection.rb +35 -35
- data/lib/aws/s3/object_metadata.rb +6 -6
- data/lib/aws/s3/object_version.rb +4 -4
- data/lib/aws/s3/object_version_collection.rb +15 -15
- data/lib/aws/s3/policy.rb +2 -2
- data/lib/aws/s3/prefixed_collection.rb +9 -5
- data/lib/aws/s3/presigned_post.rb +39 -37
- data/lib/aws/s3/request.rb +11 -11
- data/lib/aws/s3/s3_object.rb +210 -200
- data/lib/aws/s3/tree.rb +25 -27
- data/lib/aws/s3/tree/child_collection.rb +3 -3
- data/lib/aws/s3/tree/leaf_node.rb +2 -2
- data/lib/aws/s3/tree/parent.rb +1 -1
- data/lib/aws/s3/website_configuration.rb +13 -13
- data/lib/aws/simple_db.rb +83 -83
- data/lib/aws/simple_db/attribute.rb +9 -7
- data/lib/aws/simple_db/attribute_collection.rb +22 -13
- data/lib/aws/simple_db/client.rb +107 -107
- data/lib/aws/simple_db/config.rb +7 -1
- data/lib/aws/simple_db/consistent_read_option.rb +5 -5
- data/lib/aws/simple_db/domain.rb +4 -2
- data/lib/aws/simple_db/domain_collection.rb +4 -4
- data/lib/aws/simple_db/domain_metadata.rb +5 -5
- data/lib/aws/simple_db/errors.rb +9 -9
- data/lib/aws/simple_db/item.rb +5 -5
- data/lib/aws/simple_db/item_collection.rb +83 -81
- data/lib/aws/simple_db/item_data.rb +4 -4
- data/lib/aws/simple_db/put_attributes.rb +3 -3
- data/lib/aws/simple_email_service.rb +140 -140
- data/lib/aws/simple_email_service/client.rb +82 -76
- data/lib/aws/simple_email_service/config.rb +1 -2
- data/lib/aws/simple_email_service/email_address_collection.rb +3 -3
- data/lib/aws/simple_email_service/identity.rb +8 -8
- data/lib/aws/simple_email_service/quotas.rb +8 -6
- data/lib/aws/simple_workflow.rb +106 -106
- data/lib/aws/simple_workflow/activity_task.rb +15 -22
- data/lib/aws/simple_workflow/activity_task_collection.rb +15 -15
- data/lib/aws/simple_workflow/activity_type.rb +23 -23
- data/lib/aws/simple_workflow/activity_type_collection.rb +23 -23
- data/lib/aws/simple_workflow/client.rb +1004 -956
- data/lib/aws/simple_workflow/config.rb +1 -1
- data/lib/aws/simple_workflow/count.rb +5 -5
- data/lib/aws/simple_workflow/decision_task.rb +129 -129
- data/lib/aws/simple_workflow/decision_task_collection.rb +59 -59
- data/lib/aws/simple_workflow/domain.rb +11 -11
- data/lib/aws/simple_workflow/domain_collection.rb +26 -26
- data/lib/aws/simple_workflow/history_event.rb +32 -32
- data/lib/aws/simple_workflow/history_event_collection.rb +3 -3
- data/lib/aws/simple_workflow/option_formatters.rb +5 -5
- data/lib/aws/simple_workflow/request.rb +1 -1
- data/lib/aws/simple_workflow/resource.rb +1 -1
- data/lib/aws/simple_workflow/type.rb +8 -8
- data/lib/aws/simple_workflow/type_collection.rb +15 -15
- data/lib/aws/simple_workflow/workflow_execution.rb +70 -72
- data/lib/aws/simple_workflow/workflow_execution_collection.rb +130 -130
- data/lib/aws/simple_workflow/workflow_type.rb +27 -25
- data/lib/aws/simple_workflow/workflow_type_collection.rb +20 -20
- data/lib/aws/sns.rb +25 -25
- data/lib/aws/sns/client.rb +55 -55
- data/lib/aws/sns/config.rb +1 -1
- data/lib/aws/sns/policy.rb +1 -1
- data/lib/aws/sns/subscription.rb +7 -7
- data/lib/aws/sns/subscription_collection.rb +5 -5
- data/lib/aws/sns/topic.rb +49 -49
- data/lib/aws/sns/topic_collection.rb +2 -2
- data/lib/aws/sns/topic_subscription_collection.rb +5 -5
- data/lib/aws/sqs.rb +20 -20
- data/lib/aws/sqs/client.rb +78 -78
- data/lib/aws/sqs/config.rb +1 -1
- data/lib/aws/sqs/errors.rb +12 -12
- data/lib/aws/sqs/queue.rb +66 -67
- data/lib/aws/sqs/queue_collection.rb +16 -8
- data/lib/aws/sqs/received_message.rb +7 -6
- data/lib/aws/storage_gateway.rb +21 -21
- data/lib/aws/storage_gateway/client.rb +269 -202
- data/lib/aws/storage_gateway/config.rb +1 -1
- data/lib/aws/sts.rb +10 -8
- data/lib/aws/sts/client.rb +35 -35
- data/lib/aws/sts/session.rb +3 -3
- data/lib/aws/version.rb +1 -2
- metadata +23 -21
- data/lib/aws/core/autoloader.rb +0 -64
- data/lib/net/http/connection_pool.rb +0 -226
- data/lib/net/http/connection_pool/connection.rb +0 -189
- data/lib/net/http/connection_pool/session.rb +0 -126
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
# ANY KIND, either express or implied. See the License for the specific
|
|
12
12
|
# language governing permissions and limitations under the License.
|
|
13
13
|
|
|
14
|
-
require 'aws/record/attributes.rb'
|
|
15
|
-
|
|
16
14
|
module AWS
|
|
17
15
|
module Record
|
|
18
16
|
class Model
|
|
@@ -46,24 +44,24 @@ module AWS
|
|
|
46
44
|
range.is_a?(Range) and range.first.is_a?(Integer)
|
|
47
45
|
super(name, options)
|
|
48
46
|
end
|
|
49
|
-
|
|
47
|
+
|
|
50
48
|
# Returns a serialized representation of the integer value suitable for
|
|
51
49
|
# storing in SimpleDB.
|
|
52
50
|
#
|
|
53
|
-
#
|
|
54
|
-
#
|
|
51
|
+
# attribute.serialize(123)
|
|
52
|
+
# #=> '123'
|
|
55
53
|
#
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
#
|
|
54
|
+
# # padded to the correct number of digits
|
|
55
|
+
# attribute.serialize('123', :range => (0..10_000)
|
|
56
|
+
# #=> '00123'
|
|
59
57
|
#
|
|
60
|
-
#
|
|
61
|
-
#
|
|
62
|
-
#
|
|
58
|
+
# # offset applied to make all values positive
|
|
59
|
+
# attribute.serialize('-55', :range => (-100..10_000)
|
|
60
|
+
# #=> '00045'
|
|
63
61
|
#
|
|
64
62
|
# @param [Integer] integer The number to serialize.
|
|
65
63
|
# @param [Hash] options
|
|
66
|
-
# @option options [required,Range] :range A range that represents the
|
|
64
|
+
# @option options [required,Range] :range A range that represents the
|
|
67
65
|
# minimum and maximum values this integer can be.
|
|
68
66
|
# The returned value will have an offset applied (if min is
|
|
69
67
|
# less than 0) and will be zero padded.
|
|
@@ -117,7 +115,7 @@ module AWS
|
|
|
117
115
|
end
|
|
118
116
|
|
|
119
117
|
def self.serialize float, options = {}
|
|
120
|
-
expect(Float, float) do
|
|
118
|
+
expect(Float, float) do
|
|
121
119
|
left, right = float.to_s.split('.')
|
|
122
120
|
left = SortableIntegerAttr.serialize(left.to_i, options)
|
|
123
121
|
SortableIntegerAttr.check_range(float, options)
|
|
@@ -138,7 +136,7 @@ module AWS
|
|
|
138
136
|
end
|
|
139
137
|
|
|
140
138
|
class << self
|
|
141
|
-
|
|
139
|
+
|
|
142
140
|
# Adds a string attribute to this class.
|
|
143
141
|
#
|
|
144
142
|
# @example A standard string attribute
|
|
@@ -150,14 +148,14 @@ module AWS
|
|
|
150
148
|
# recipe = Recipe.new(:name => "Buttermilk Pancakes")
|
|
151
149
|
# recipe.name #=> 'Buttermilk Pancakes'
|
|
152
150
|
#
|
|
153
|
-
# @example A string attribute with
|
|
151
|
+
# @example A string attribute with `:set` set to true
|
|
154
152
|
#
|
|
155
153
|
# class Recipe < AWS::Record::Model
|
|
156
154
|
# string_attr :tags, :set => true
|
|
157
155
|
# end
|
|
158
156
|
#
|
|
159
157
|
# recipe = Recipe.new(:tags => %w(popular dessert))
|
|
160
|
-
# recipe.tags #=> #<Set: {"popular", "desert"}>
|
|
158
|
+
# recipe.tags #=> #<Set: {"popular", "desert"}>
|
|
161
159
|
#
|
|
162
160
|
# @param [Symbol] name The name of the attribute.
|
|
163
161
|
# @param [Hash] options
|
|
@@ -166,15 +164,15 @@ module AWS
|
|
|
166
164
|
def string_attr name, options = {}
|
|
167
165
|
add_attribute(Record::Attributes::StringAttr.new(name, options))
|
|
168
166
|
end
|
|
169
|
-
|
|
167
|
+
|
|
170
168
|
# Adds an integer attribute to this class.
|
|
171
169
|
#
|
|
172
|
-
#
|
|
173
|
-
#
|
|
174
|
-
#
|
|
170
|
+
# class Recipe < AWS::Record::Model
|
|
171
|
+
# integer_attr :servings
|
|
172
|
+
# end
|
|
175
173
|
#
|
|
176
|
-
#
|
|
177
|
-
#
|
|
174
|
+
# recipe = Recipe.new(:servings => '10')
|
|
175
|
+
# recipe.servings #=> 10
|
|
178
176
|
#
|
|
179
177
|
# @param [Symbol] name The name of the attribute.
|
|
180
178
|
# @param [Hash] options
|
|
@@ -183,24 +181,24 @@ module AWS
|
|
|
183
181
|
def integer_attr name, options = {}
|
|
184
182
|
add_attribute(Attributes::IntegerAttr.new(name, options))
|
|
185
183
|
end
|
|
186
|
-
|
|
184
|
+
|
|
187
185
|
# Adds a sortable integer attribute to this class.
|
|
188
186
|
#
|
|
189
|
-
#
|
|
190
|
-
#
|
|
191
|
-
#
|
|
187
|
+
# class Person < AWS::Record::Model
|
|
188
|
+
# sortable_integer_attr :age, :range => 0..150
|
|
189
|
+
# end
|
|
192
190
|
#
|
|
193
|
-
#
|
|
194
|
-
#
|
|
191
|
+
# person = Person.new(:age => 10)
|
|
192
|
+
# person.age #=> 10
|
|
193
|
+
#
|
|
194
|
+
# ### Validations
|
|
195
195
|
#
|
|
196
|
-
# === Validations
|
|
197
|
-
#
|
|
198
196
|
# It is recomended to apply a validates_numericality_of with
|
|
199
197
|
# minimum and maximum value constraints. If a value is assigned
|
|
200
198
|
# to a sortable integer that falls outside of the +:range: it will
|
|
201
199
|
# raise a runtime error when the record is saved.
|
|
202
200
|
#
|
|
203
|
-
#
|
|
201
|
+
# ### Difference Between Sortable an Regular Integer Attributes
|
|
204
202
|
#
|
|
205
203
|
# Because SimpleDB does not support numeric types, all values must
|
|
206
204
|
# be converted to strings. This complicates sorting by numeric values.
|
|
@@ -216,15 +214,15 @@ module AWS
|
|
|
216
214
|
def sortable_integer_attr name, options = {}
|
|
217
215
|
add_attribute(Attributes::SortableIntegerAttr.new(name, options))
|
|
218
216
|
end
|
|
219
|
-
|
|
217
|
+
|
|
220
218
|
# Adds a float attribute to this class.
|
|
221
219
|
#
|
|
222
|
-
#
|
|
223
|
-
#
|
|
224
|
-
#
|
|
220
|
+
# class Listing < AWS::Record::Model
|
|
221
|
+
# float_attr :score
|
|
222
|
+
# end
|
|
225
223
|
#
|
|
226
|
-
#
|
|
227
|
-
#
|
|
224
|
+
# listing = Listing.new(:score => '123.456')
|
|
225
|
+
# listing.score # => 123.456
|
|
228
226
|
#
|
|
229
227
|
# @param [Symbol] name The name of the attribute.
|
|
230
228
|
# @param [Hash] options
|
|
@@ -233,35 +231,35 @@ module AWS
|
|
|
233
231
|
def float_attr name, options = {}
|
|
234
232
|
add_attribute(Attributes::FloatAttr.new(name, options))
|
|
235
233
|
end
|
|
236
|
-
|
|
234
|
+
|
|
237
235
|
# Adds sortable float attribute to this class.
|
|
238
236
|
#
|
|
239
237
|
# Persisted values are stored (and sorted) as strings. This makes it
|
|
240
|
-
# more difficult to sort numbers because they don't sort
|
|
238
|
+
# more difficult to sort numbers because they don't sort
|
|
241
239
|
# lexicographically unless they have been offset to be positive and
|
|
242
240
|
# then zero padded.
|
|
243
241
|
#
|
|
244
|
-
#
|
|
242
|
+
# ### Postive Floats
|
|
245
243
|
#
|
|
246
244
|
# To store floats in a sort-friendly manor:
|
|
247
245
|
#
|
|
248
|
-
#
|
|
246
|
+
# sortable_float_attr :score, :range => (0..10)
|
|
249
247
|
#
|
|
250
|
-
# This will cause values like 5.5 to persist as a string like '05.5' so
|
|
248
|
+
# This will cause values like 5.5 to persist as a string like '05.5' so
|
|
251
249
|
# that they can be sorted lexicographically.
|
|
252
250
|
#
|
|
253
|
-
#
|
|
251
|
+
# ### Negative Floats
|
|
254
252
|
#
|
|
255
|
-
# If you need to store negative sortable floats, increase your
|
|
253
|
+
# If you need to store negative sortable floats, increase your `:range`
|
|
256
254
|
# to include a negative value.
|
|
257
255
|
#
|
|
258
|
-
#
|
|
256
|
+
# sortable_float_attr :position, :range => (-10..10)
|
|
259
257
|
#
|
|
260
|
-
# AWS::Record will add 10 to all values and zero pad them
|
|
261
|
-
# (e.g. -10.0 will be represented as '00.0' and 10 will be represented as
|
|
258
|
+
# AWS::Record will add 10 to all values and zero pad them
|
|
259
|
+
# (e.g. -10.0 will be represented as '00.0' and 10 will be represented as
|
|
262
260
|
# '20.0'). This will allow the values to be compared lexicographically.
|
|
263
261
|
#
|
|
264
|
-
# @note If you change the
|
|
262
|
+
# @note If you change the `:range` after some values have been persisted
|
|
265
263
|
# you must also manually migrate all of the old values to have the
|
|
266
264
|
# correct padding & offset or they will be interpreted differently.
|
|
267
265
|
#
|
|
@@ -276,7 +274,7 @@ module AWS
|
|
|
276
274
|
def sortable_float_attr name, options = {}
|
|
277
275
|
add_attribute(Attributes::SortableFloatAttr.new(name, options))
|
|
278
276
|
end
|
|
279
|
-
|
|
277
|
+
|
|
280
278
|
# Adds a boolean attribute to this class.
|
|
281
279
|
#
|
|
282
280
|
# @example
|
|
@@ -295,16 +293,16 @@ module AWS
|
|
|
295
293
|
#
|
|
296
294
|
# @param [Symbol] name The name of the attribute.
|
|
297
295
|
def boolean_attr name, options = {}
|
|
298
|
-
|
|
296
|
+
|
|
299
297
|
attr = add_attribute(Attributes::BooleanAttr.new(name, options))
|
|
300
|
-
|
|
298
|
+
|
|
301
299
|
# add the boolean question mark method
|
|
302
300
|
define_method("#{attr.name}?") do
|
|
303
301
|
!!__send__(attr.name)
|
|
304
302
|
end
|
|
305
|
-
|
|
303
|
+
|
|
306
304
|
end
|
|
307
|
-
|
|
305
|
+
|
|
308
306
|
# Adds a datetime attribute to this class.
|
|
309
307
|
#
|
|
310
308
|
# @example A standard datetime attribute
|
|
@@ -316,7 +314,7 @@ module AWS
|
|
|
316
314
|
# recipe = Recipe.new(:invented => Time.now)
|
|
317
315
|
# recipe.invented #=> <DateTime ...>
|
|
318
316
|
#
|
|
319
|
-
# If you add a datetime_attr for
|
|
317
|
+
# If you add a datetime_attr for `:created_at` and/or `:updated_at` those
|
|
320
318
|
# will be automanaged.
|
|
321
319
|
#
|
|
322
320
|
# @param [Symbol] name The name of the attribute.
|
|
@@ -329,7 +327,7 @@ module AWS
|
|
|
329
327
|
def datetime_attr name, options = {}
|
|
330
328
|
add_attribute(Record::Attributes::DateTimeAttr.new(name, options))
|
|
331
329
|
end
|
|
332
|
-
|
|
330
|
+
|
|
333
331
|
# Adds a date attribute to this class.
|
|
334
332
|
#
|
|
335
333
|
# @example A standard date attribute
|
|
@@ -352,9 +350,9 @@ module AWS
|
|
|
352
350
|
def date_attr name, options = {}
|
|
353
351
|
add_attribute(Record::Attributes::DateAttr.new(name, options))
|
|
354
352
|
end
|
|
355
|
-
|
|
353
|
+
|
|
356
354
|
# A convenience method for adding the standard two datetime attributes
|
|
357
|
-
#
|
|
355
|
+
# `:created_at` and `:updated_at`.
|
|
358
356
|
#
|
|
359
357
|
# @example
|
|
360
358
|
#
|
|
@@ -366,13 +364,13 @@ module AWS
|
|
|
366
364
|
# recipe.save
|
|
367
365
|
# recipe.created_at #=> <DateTime ...>
|
|
368
366
|
# recipe.updated_at #=> <DateTime ...>
|
|
369
|
-
#
|
|
367
|
+
#
|
|
370
368
|
def timestamps
|
|
371
369
|
c = datetime_attr :created_at
|
|
372
370
|
u = datetime_attr :updated_at
|
|
373
371
|
[c, u]
|
|
374
372
|
end
|
|
375
|
-
|
|
373
|
+
|
|
376
374
|
end
|
|
377
375
|
end
|
|
378
376
|
end
|
|
@@ -24,46 +24,46 @@ module AWS
|
|
|
24
24
|
# was no data found for the given id.
|
|
25
25
|
# @return [Record::HashModel] Returns the record with the given id.
|
|
26
26
|
def find_by_id id, options = {}
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
domain = sdb_domain(options[:shard] || options[:domain])
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
data = domain.items[id].data.attributes
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
raise RecordNotFound, "no data found for id: #{id}" if data.empty?
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
obj = self.new(:shard => domain)
|
|
35
35
|
obj.send(:hydrate, id, data)
|
|
36
36
|
obj
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
end
|
|
39
39
|
alias_method :[], :find_by_id
|
|
40
|
-
|
|
41
|
-
# Finds records in SimpleDB and returns them as objects of the
|
|
40
|
+
|
|
41
|
+
# Finds records in SimpleDB and returns them as objects of the
|
|
42
42
|
# current class.
|
|
43
43
|
#
|
|
44
|
-
# Finding
|
|
44
|
+
# Finding `:all` returns an enumerable scope object
|
|
45
45
|
#
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
#
|
|
46
|
+
# People.find(:all, :order => [:age, :desc], :limit => 10).each do |person|
|
|
47
|
+
# puts person.name
|
|
48
|
+
# end
|
|
49
49
|
#
|
|
50
|
-
# Finding
|
|
50
|
+
# Finding `:first` returns a single record (or nil)
|
|
51
51
|
#
|
|
52
|
-
#
|
|
52
|
+
# boss = People.find(:first, :where => { :boss => true })
|
|
53
53
|
#
|
|
54
|
-
# Find accepts a hash of find modifiers (
|
|
55
|
-
#
|
|
54
|
+
# Find accepts a hash of find modifiers (`:where`, `:order` and
|
|
55
|
+
# `:limit`). You can also choose to omit these modifiers and
|
|
56
56
|
# chain them on the scope object returned. In the following
|
|
57
57
|
# example only one request is made to SimpleDB (when #each is
|
|
58
58
|
# called)
|
|
59
59
|
#
|
|
60
|
-
#
|
|
60
|
+
# people = People.find(:all)
|
|
61
61
|
#
|
|
62
|
-
#
|
|
62
|
+
# johns = people.where(:name => 'John Doe')
|
|
63
63
|
#
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
|
-
#
|
|
64
|
+
# johns.order(:age, :desc).limit(10).each do |suspects|
|
|
65
|
+
# # ...
|
|
66
|
+
# end
|
|
67
67
|
#
|
|
68
68
|
# See also {where}, {order} and {limit} for more
|
|
69
69
|
# information and options.
|
|
@@ -73,25 +73,25 @@ module AWS
|
|
|
73
73
|
# not found.
|
|
74
74
|
#
|
|
75
75
|
# @overload find(mode, options = {})
|
|
76
|
-
# @param [:all,:first] mode (:all) When finding
|
|
77
|
-
# and array is returned of records. When finding
|
|
78
|
-
#
|
|
76
|
+
# @param [:all,:first] mode (:all) When finding `:all` matching records
|
|
77
|
+
# and array is returned of records. When finding `:first` then
|
|
78
|
+
# `nil` or a single record will be returned.
|
|
79
79
|
# @param [Hash] options
|
|
80
80
|
# @option options [Mixed] :where Conditions that determine what
|
|
81
81
|
# records are returned.
|
|
82
|
-
# @option options [String,Array] :sort The order records should be
|
|
82
|
+
# @option options [String,Array] :sort The order records should be
|
|
83
83
|
# returned in.
|
|
84
84
|
# @option options [Integer] :limit The max number of records to fetch.
|
|
85
85
|
def find *args
|
|
86
86
|
new_scope.find(*args)
|
|
87
87
|
end
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
# Returns a chainable scope object that restricts further scopes to a
|
|
90
90
|
# particular domain.
|
|
91
91
|
#
|
|
92
|
-
#
|
|
93
|
-
#
|
|
94
|
-
#
|
|
92
|
+
# Book.domain('books-2').each do |book|
|
|
93
|
+
# # ...
|
|
94
|
+
# end
|
|
95
95
|
#
|
|
96
96
|
# @param [String] shard_name
|
|
97
97
|
# @return [Scope] Returns a scope for restricting the domain of subsequent
|
|
@@ -99,20 +99,20 @@ module AWS
|
|
|
99
99
|
new_scope.shard(shard_name)
|
|
100
100
|
end
|
|
101
101
|
alias_method :domain, :shard
|
|
102
|
-
|
|
102
|
+
|
|
103
103
|
# Returns an enumerable scope object represents all records.
|
|
104
104
|
#
|
|
105
|
-
#
|
|
106
|
-
#
|
|
107
|
-
#
|
|
105
|
+
# Book.all.each do |book|
|
|
106
|
+
# # ...
|
|
107
|
+
# end
|
|
108
108
|
#
|
|
109
|
-
# This method is equivalent to
|
|
110
|
-
# pass aditional options. See {.find} for more information on what
|
|
109
|
+
# This method is equivalent to `find(:all)`, and therefore you can also
|
|
110
|
+
# pass aditional options. See {.find} for more information on what
|
|
111
111
|
# options you can pass.
|
|
112
112
|
#
|
|
113
|
-
#
|
|
114
|
-
#
|
|
115
|
-
#
|
|
113
|
+
# Book.all(:where => { :author' => 'me' }).each do |my_book|
|
|
114
|
+
# # ...
|
|
115
|
+
# end
|
|
116
116
|
#
|
|
117
117
|
# @return [Scope] Returns an enumerable scope object.
|
|
118
118
|
def all options = {}
|
|
@@ -123,20 +123,20 @@ module AWS
|
|
|
123
123
|
def each &block
|
|
124
124
|
all.each(&block)
|
|
125
125
|
end
|
|
126
|
-
|
|
126
|
+
|
|
127
127
|
# Counts records in SimpleDB.
|
|
128
128
|
#
|
|
129
129
|
# With no arguments, counts all records:
|
|
130
130
|
#
|
|
131
|
-
#
|
|
131
|
+
# People.count
|
|
132
132
|
#
|
|
133
133
|
# Accepts query options to count a subset of records:
|
|
134
134
|
#
|
|
135
|
-
#
|
|
135
|
+
# People.count(:where => { :boss => true })
|
|
136
136
|
#
|
|
137
137
|
# You can also count records on a scope object:
|
|
138
138
|
#
|
|
139
|
-
#
|
|
139
|
+
# People.find(:all).where(:boss => true).count
|
|
140
140
|
#
|
|
141
141
|
# See {find} and {Scope#count} for more details.
|
|
142
142
|
#
|
|
@@ -150,43 +150,43 @@ module AWS
|
|
|
150
150
|
new_scope.count(options)
|
|
151
151
|
end
|
|
152
152
|
alias_method :size, :count
|
|
153
|
-
|
|
153
|
+
|
|
154
154
|
# @return [Object,nil] Returns the first record found. If there were
|
|
155
155
|
# no records found, nil is returned.
|
|
156
156
|
def first options = {}
|
|
157
157
|
new_scope.first(options)
|
|
158
158
|
end
|
|
159
|
-
|
|
159
|
+
|
|
160
160
|
# Limits which records are retried from SimpleDB when performing a find.
|
|
161
|
-
#
|
|
161
|
+
#
|
|
162
162
|
# Simple string condition
|
|
163
163
|
#
|
|
164
|
-
#
|
|
165
|
-
#
|
|
164
|
+
# Car.where('color = "red" or color = "blue"').each {|car| ... }
|
|
165
|
+
#
|
|
166
166
|
# String with placeholders for quoting params
|
|
167
167
|
#
|
|
168
|
-
#
|
|
168
|
+
# Car.where('color = ?', 'red')
|
|
169
|
+
#
|
|
170
|
+
# Car.where('color = ? OR style = ?', 'red', 'compact')
|
|
169
171
|
#
|
|
170
|
-
#
|
|
172
|
+
# # produces a condition using in, like: WHERE color IN ('red', 'blue')
|
|
173
|
+
# Car.where('color IN ?', ['red','blue'])
|
|
171
174
|
#
|
|
172
|
-
# # produces a condition using in, like: WHERE color IN ('red', 'blue')
|
|
173
|
-
# Car.where('color IN ?', ['red','blue'])
|
|
174
|
-
#
|
|
175
175
|
# Hash arguments
|
|
176
176
|
#
|
|
177
|
-
#
|
|
178
|
-
#
|
|
177
|
+
# # WHERE age = '40' AND gender = 'male'
|
|
178
|
+
# People.where(:age => 40, :gender => 'male').each {|person| ... }
|
|
179
179
|
#
|
|
180
|
-
#
|
|
181
|
-
#
|
|
180
|
+
# # WHERE name IN ('John', 'Jane')
|
|
181
|
+
# People.where(:name => ['John', 'Jane']).each{|person| ... }
|
|
182
182
|
#
|
|
183
183
|
# Chaining where with other scope modifiers
|
|
184
184
|
#
|
|
185
|
-
#
|
|
186
|
-
#
|
|
187
|
-
#
|
|
185
|
+
# # 10 most expensive red cars
|
|
186
|
+
# Car.where(:color => 'red').order(:price, :desc).limit(10)
|
|
187
|
+
#
|
|
188
188
|
# @overload where(conditions_hash)
|
|
189
|
-
# @param [Hash] conditions_hash A hash of attributes to values. Each
|
|
189
|
+
# @param [Hash] conditions_hash A hash of attributes to values. Each
|
|
190
190
|
# key/value pair from the hash becomes a find condition. All
|
|
191
191
|
# conditions are joined by AND.
|
|
192
192
|
#
|
|
@@ -195,16 +195,16 @@ module AWS
|
|
|
195
195
|
def where *args
|
|
196
196
|
new_scope.where(*args)
|
|
197
197
|
end
|
|
198
|
-
|
|
198
|
+
|
|
199
199
|
# Defines the order in which records are returned when performing a find.
|
|
200
200
|
# SimpleDB only allows sorting by one attribute per request.
|
|
201
201
|
#
|
|
202
|
-
#
|
|
203
|
-
#
|
|
202
|
+
# # oldest to youngest
|
|
203
|
+
# People.order(:age, :desc).each {|person| ... }
|
|
204
204
|
#
|
|
205
205
|
# You can chain order with the other scope modifiers:
|
|
206
206
|
#
|
|
207
|
-
#
|
|
207
|
+
# Pepole.order(:age, :desc).limit(10).each {|person| ... }
|
|
208
208
|
#
|
|
209
209
|
# @overload order(attribute, direction = :asc)
|
|
210
210
|
# @param [String,Symbol] attribute The attribute to sort by.
|
|
@@ -212,15 +212,15 @@ module AWS
|
|
|
212
212
|
def order *args
|
|
213
213
|
new_scope.order(*args)
|
|
214
214
|
end
|
|
215
|
-
|
|
215
|
+
|
|
216
216
|
# The maximum number of records to return. By default, all records
|
|
217
217
|
# matching the where conditions will be returned from a find.
|
|
218
|
-
#
|
|
219
|
-
#
|
|
218
|
+
#
|
|
219
|
+
# People.limit(10).each {|person| ... }
|
|
220
220
|
#
|
|
221
221
|
# Limit can be chained with other scope modifiers:
|
|
222
222
|
#
|
|
223
|
-
#
|
|
223
|
+
# People.where(:age => 40).limit(10).each {|person| ... }
|
|
224
224
|
#
|
|
225
225
|
def limit limit
|
|
226
226
|
new_scope.limit(limit)
|