Sha256: b589a2e6bb6cdc1831e1478dd7434b366474b33b5d7f33e40ada7f1428555e67

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

module SurveyGizmo; module API
  # @see SurveyGizmo::Resource::ClassMethods
  class Page
    include SurveyGizmo::Resource

    attribute :id,            Integer
    attribute :title,         Hash
    attribute :description,   String
    attribute :properties,    Hash
    attribute :after,         Integer
    attribute :survey_id,     Integer

    # routing
    route '/survey/:survey_id/surveypage', :via => :create
    route '/survey/:survey_id/surveypage/:id', :via => [:get, :update, :delete]

    def survey
      @survey ||= SurveyGizmo::API::Survey.first(id: survey_id)
    end

    def questions
      @questions ||= SurveyGizmo::API::Question.all(survey_id: survey_id, page_id: id)
    end

    # survey gizmo sends a hash back for :title
    def title_with_multilingual=(val)
      self.title_without_multilingual = val.is_a?(Hash) ? val : { 'English' => val }
    end

    alias_method_chain :title=, :multilingual

    def to_param_options
      { id: self.id, survey_id: self.survey_id }
    end
  end
end; end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
survey-gizmo-ruby-3.0.3 lib/survey_gizmo/api/page.rb