Sha256: 2ff76725df66286b5626ed4d2e112ca8194ee36b5ba767e71a5696e4b6f80c91

Contents?: true

Size: 1019 Bytes

Versions: 4

Compression:

Stored size: 1019 Bytes

Contents

module Passworks
  module Inflector

    # Return the singular version of the *curren_collection* name
    # @return [String] singular version of the current collection name
    def single_name
      case collection_name
      when 'assets'
        'asset'
      when 'boarding_passes'
        'boarding_pass'
      when 'coupons'
        'coupon'
      when 'store_cards'
        'store_card'
      when 'event_tickets'
        'event_ticket'
      when 'generics'
        'generic'
      else
        raise 'Invalid Collection Name'
      end
    end

    # Return resource class based in collection_name and collection_uuid
    # If collection_name  return [Passworks::AssetResource]
    # If  collection_uuid == nil return [Passworks::CampaignResource] else return [Passworks::PassResource]
    def resource_class
      return Passworks::AssetResource if collection_name == 'assets'
      if collection_uuid
        Passworks::PassResource
      else
        Passworks::CampaignResource
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
passworks-0.0.4 lib/passworks/inflector.rb
passworks-0.0.3 lib/passworks/inflector.rb
passworks-0.0.2 lib/passworks/inflector.rb
passworks-0.0.1 lib/passworks/inflector.rb